3

I just want my asp.net webpage to reload after changing my combobox selected value. So I did

    protected void MyComboBox_SelectedIndexChanged(object sender, EventArgs e)
    {
        Response.Redirect(Request.RawUrl);
    }

I used Response.Redirect(Request.RawUrl) according to How do I refresh the page in ASP.NET? (Let it reload itself by code)

But when I change selection in my combo page is not reloaded.

Why, how to do so ?

Community
  • 1
  • 1
user310291
  • 36,946
  • 82
  • 271
  • 487
  • Pointless, you lose the drop down selection. – Aristos Oct 04 '12 at 23:19
  • @Aristos wouldn't ViewState save the state? – sshow Oct 04 '12 at 23:21
  • 1
    The redirect you make here is reload the page and forget anything from previous selections, and viewstate. Only the post back can keep the previous data (and viewstate). – Aristos Oct 04 '12 at 23:23
  • Remove the `Response.Redirect` and only place the `AutoPostBack=true` - with other words, your question is how to make the Redirect to work, and I say, DO NOT make redirect, only set the AutoPostBack. – Aristos Oct 04 '12 at 23:24

2 Answers2

2

Make sure you have defined the SelectedIndexChanged event on the control itself.

Edit: Enable AutoPostback on the control as well, like Abe Miessler points out.

AutoPostBack="true"  
OnSelectedIndexChanged="MyComboBox_SelectedIndexChanged"
sshow
  • 8,820
  • 4
  • 51
  • 82
2

Try setting autopostback = true. You haven't posted your markup but I suspect that would fix it.

Abe Miessler
  • 82,532
  • 99
  • 305
  • 486