开发者

Drop Down Box (select) set URL on postback?

I have a page with a 开发者_如何学运维ASP.NET DropDownBox control (HTML select) that's populated with some dynamic record values. When the user selects a record the entire contents of the page is updated to reflect the selection. If a user clicks a link and leaves the page and tries to go back, it pulls up the default unselected list, and they have to reselect it again. How would be the best way to retain their selection? I currently have the page set so if the url contains PageName.aspx?recordID=5 it will select the correct dropDown option. However I'm not sure how to change the URL's query string based on the selection.


You could throw the recordID into ViewState

ViewState["recordID"] = 5;

instead of carrying the selection in Query String. You can check for it on page load; if it's not null then set the dropdown control appropriately.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜