Search code examples
asp.netvb.netdrop-down-menupostbackautopostback

ASP DropDown causing ViewState to appear in Address bar


If you visit this page in Internet explorer, and choose a value from the "Current Media Releases" dropdown on the top right, eventually IE will try to redirect you to an ugly url containing this string:

__EVENTTARGET=selArchives&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=

The page should only be updating the selArchives Query string value.

The drop down has AutoPostBack set to true and the codebehind is in VB, here is the event handler:

Private Sub selArchives_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles selArchives.SelectedIndexChanged
    Response.Redirect("index.aspx?selArchives=" + selArchives.SelectedValue)
End Sub

Obviously, I could just write the JavaScript myself, but I would like to find the source of the problem.


Not sure what specifically was causing the problem. Looks like it was a combination of a few factors.

Thanks for the help


Solution

  • First off, your page has javascript errors. Please fix them.

    Second, you only see the ugly url when you select a date and click the go button. But you've got the dropdown set to auto postback. Ditch the button; you don't need it.

    There's something screwy with the button in your codebehind. And the dropdown, as well, since it stops working after a few uses.

    You'll have to post your page's source for any more help.