Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to cancel PostBack?

Status
Not open for further replies.

vladibo

Programmer
Sep 14, 2003
161
CA
I need to cancel PostBack on the server side (I know how to do that on client side but this is not what I need).

That's my current solution.

protected void Page_Load(object sender, System.EventArgs e){
if(ShouldBeCanceled){
Response.Redirect(Request.Url.ToString());
Response.End();
}
}

Is there some kind of more intelligent way (not depending on JavaScript client support) way?
 
Actually my complete code is this:

protected void Page_Load(object sender, System.EventArgs e){
if(IsPostBack && ShouldBeCanceled){
Response.Redirect(Request.Url.ToString());
Response.End();
}
}
 
this actually only cancels the execution of the current page, but the postback takes place, so the data is sent from the browser to the server.

why do you need to cancel the postback?

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
The data is sent but is not processed.

I implement system for taking ownership of each system object. If the current user does not have ownership his request should not be accepted.
 
then this sounds like a good idea

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top