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 ?

4
  • Pointless, you lose the drop down selection. Commented Oct 4, 2012 at 23:19
  • @Aristos wouldn't ViewState save the state? Commented Oct 4, 2012 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). Commented Oct 4, 2012 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. Commented Oct 4, 2012 at 23:24

2 Answers 2

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"
Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.