Html Attribute for Html.Dropdown
Posted
by kapil
on Stack Overflow
See other posts from Stack Overflow
or by kapil
Published on 2010-02-08T13:54:25Z
Indexed on
2010/05/02
15:08 UTC
Read the original article
Hit count: 538
I am using a dropdown list as follows.
<%=Html.DropDownList("ddl", ViewData["Available"] as SelectList,
new { CssClass = "input-config", onchange = "this.form.submit();" })%>
On its selection change I am invoking post action. After the post the same page is shown on which this drop down is present. I want to know about the HTML attribute for the drop down which will let me preserve the list selection change. But as of now the list shows its first element after the post. e.g. The dropdoen contains elements like 1,2,3,etc. By default 1 is selected. If I select 2, the post is invoked and the same page is shown again but my selection 2 goes and 1 is selected again. How can preserve the selection?
Thanks, Kapil
© Stack Overflow or respective owner