Cancel a postback
-
Dear CPians, I am using the
Page.IsPostBack
property. When this evaluates to true, hence I am within a post back, I want, in some cases to cancel the post back. I need to prevent it of happening in case some condition evaluates to true. Example:if (Page.IsPostBack)
{
if (something == true)
{
DO SOMETHING TO CANCEL THE POSTBACK
}
}Is there a way to prevent it of happening? Thanking you in advance
Excellence is not an act, but a habit!
Aristotle
-
Dear CPians, I am using the
Page.IsPostBack
property. When this evaluates to true, hence I am within a post back, I want, in some cases to cancel the post back. I need to prevent it of happening in case some condition evaluates to true. Example:if (Page.IsPostBack)
{
if (something == true)
{
DO SOMETHING TO CANCEL THE POSTBACK
}
}Is there a way to prevent it of happening? Thanking you in advance
Excellence is not an act, but a habit!
Aristotle
-
What exactly do you mean cancel the postback? You could use Response.Redirect() or Response.End() but I don't think thats exactly what your after. Please explain more.
Actually a redirect would do it. thanx
Excellence is not an act, but a habit!
Aristotle
-
Dear CPians, I am using the
Page.IsPostBack
property. When this evaluates to true, hence I am within a post back, I want, in some cases to cancel the post back. I need to prevent it of happening in case some condition evaluates to true. Example:if (Page.IsPostBack)
{
if (something == true)
{
DO SOMETHING TO CANCEL THE POSTBACK
}
}Is there a way to prevent it of happening? Thanking you in advance
Excellence is not an act, but a habit!
Aristotle
I may be misunderstanding what you're trying to accomplish, but it sounds to me as if you should be doing your evaluation on the client-side and preventing the form submission rather then trying to evaluate it on the server after the postback has already taken place. More information on what kind of conditions you're evaluating would prove helpful, if you're still interested in gathering opinions.
--Jesse
-
Dear CPians, I am using the
Page.IsPostBack
property. When this evaluates to true, hence I am within a post back, I want, in some cases to cancel the post back. I need to prevent it of happening in case some condition evaluates to true. Example:if (Page.IsPostBack)
{
if (something == true)
{
DO SOMETHING TO CANCEL THE POSTBACK
}
}Is there a way to prevent it of happening? Thanking you in advance
Excellence is not an act, but a habit!
Aristotle
If there is an event causing the post back it is best to deal with this in that event, not the Page_Load. Then if something isnt the way you want it just exit that sub.
Cleako