I have a .aspx form in which I have a combobox holding subject I retrive from a DB-table.
A submit button clicking on which questions related to that subject are viewed in a gridview.
I do it by calling the function FillGrid() in the button click event.
I also have pageindexchanging for my gridview in which FillGrid() is again called.
In my FillGrid() function I have used a try catch block. If an error occurs I want to redirect the page to error page using Response.Redirect(). The problem is this response.redirect is not working. One of the reasons of it is that on button click the form is posted twice. Because after reaching to response.redirect statement flow comes back to button click where FillGrid is called().
How can I solve this? Or to put simply, how can I prevent double posting of the form?
For example you need to link index.aspx
.
So you write this:
Response.Redirect("index.aspx", true);
But Response.redirect
is not working. Now go to design view select the button which you want to set Response.redirect
and press F4 that will open Button Properties then you need to find PostBackUrl
option and then locate your URL that you want.
See this image: