By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,854 Members | 856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,854 IT Pros & Developers. It's quick & easy.

bypass an event because server side validation failed

P: n/a
Hi
How can I prevent an event (eg button click) from happening from
within page_load?
The reason is that I want to make my existing application work for
netscape, for which there are no client side validations.
So I thought to put something like the following in the superclass of
all UI pages:

public sub page_load

me.validate()
if not me.isvalid() then
'code to prevent the event to execute goes here.
end if

end sub
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
check to see if the page is valid in your event handlers.
Nov 18 '05 #2

P: n/a
You have a mistaken idea of how to setup validation. Do NOT attempt to
validate in Page_Load. Page_Load is run before your post back event handler
(the button's Click method). The post back event handlers are where you run
validation. In fact, the button automatically calls Page.Validate() for you
unless you set its CausesValidation property to false.

You should not attempt to save any data within Page_Load either. So in your
post back event handler, the following should occur:

1. Validation. Again its automatically for buttons that have
CausesValidation=true
2. Check Page.IsValid. If true, save or take whatever action needed on the
data.

FYI: You should assume that all browsers will not run the client-side
validation code. After all, users can turn off javascript in IE. It is
essential that you write server side validation code always. Microsoft
designed validation to work that way.

I have built a replacement to Microsoft's validation, Professional
Validation And More (http://www.peterblum.com/vam/home.aspx). Its 22
validators support client-side validation on IE, IE/Mac,
Netscape/Mozilla/FireFox, Opera 7, and Safari. It overcomes numerous other
limitations that cause users to write custom code and develop hacks. It
includes a conversion utility to migrate from Microsoft validators.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

<in*******@hotmail.com> wrote in message
news:a8*************************@posting.google.co m...
Hi
How can I prevent an event (eg button click) from happening from
within page_load?
The reason is that I want to make my existing application work for
netscape, for which there are no client side validations.
So I thought to put something like the following in the superclass of
all UI pages:

public sub page_load

me.validate()
if not me.isvalid() then
'code to prevent the event to execute goes here.
end if

end sub

Nov 18 '05 #3

P: n/a
Check the page post back in the page load if it's false then the page load
has triggered on the first page load if it's true then the page load has
triggered on a post back event.
if(Page.IsPostBack != true)
{
Globals.Account = true;
Globals.Navigation(this, Globals.Parameter(this, "mi"),
Globals.Parameter(this, "si"), Globals.Parameter(this, "ni"),
Globals.Parameter(this, "ln"));
this.CurrentCulture =
System.Globalization.CultureInfo.CreateSpecificCul ture(Session["Language"].ToString());
Browser.Accept = "text/*";
Menuloader(null);
Traductor(null);
Visualization(null);
RightPane.Controls.Add(Page.LoadControl("~/controls/search.ascx"));
string win = "false";
Rx.Attributes.Remove("onsubmit");
Page.RegisterHiddenField("__EVENTTARGET", "Submit");
Rx.Attributes.Add("onsubmit","javascript: validation("+ win +");");
}
Session["UrlRedirect"] = Request.Url.ToString();
Enrique.
<in*******@hotmail.com> wrote in message
news:a8*************************@posting.google.co m...
Hi
How can I prevent an event (eg button click) from happening from
within page_load?
The reason is that I want to make my existing application work for
netscape, for which there are no client side validations.
So I thought to put something like the following in the superclass of
all UI pages:

public sub page_load

me.validate()
if not me.isvalid() then
'code to prevent the event to execute goes here.
end if

end sub

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.