Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# How to set the autopostback property when using asp.net mvc?

Tags:

I am using asp.net MVC framework. On my page i have a dropdwonbox and when an option is clicked i want to go to another page. But i can't find how/where to set the autopostback property to true. This is the code i'm using:

Aspx:

<%= Html.DropDownList("qchap", new SelectList( (IEnumerable)ViewData["qchap"], "Id", "Title" )) %> 

Controller:

public ActionResult Index(int id) {     Chapter c =  new Chapter();     ViewData["qchap"] = c.GetAllChaptersByManual(id);      return View(); } 

What do i have to do to use the autopostback functionality?

like image 518
Martijn Avatar asked Apr 08 '09 16:04

Martijn


1 Answers

You can use the onchange client event:

<%= Html.DropDownList("qchap",         new SelectList( (IEnumerable)ViewData["qchap"], "Id", "Title" ),        new { onchange = "this.form.submit();" }) %> 
like image 161
Christian C. Salvadó Avatar answered Nov 12 '22 04:11

Christian C. Salvadó