473,386 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

bypass an event because server side validation failed

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
3 2401
check to see if the page is valid in your event handlers.
Nov 18 '05 #2
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Corey Olsen | last post by:
Can anyone point me to some documentation on bypassing validation controls when a user selects cancel? What I have is a user control with a form to fill out information on a subject. The user...
14
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
4
by: usl2222 | last post by:
Hi folks, I appreciate any assistance in the following problem: I have a form with a bunch of dynamic controls on it. All the controls are dynamically generated on a server, including all...
1
by: IkBenHet | last post by:
Hello, Currently I am using a large input form on a website that is based on ASP and JavaScript. Depending on the values that are filled in by the user the forms does a refresh and makes...
1
by: rmccinc | last post by:
OK, I am running into some issues that I cant figure out a work-around. I am not going to post code cause I figured out WHY my issue is happening: -I have a datagrid, and a button that fires a...
0
by: Demetri | last post by:
I have created a web control that can be rendered as either a linkbutton or a button. It is a ConfirmButton control that allows a developer to force a user to confirm if they intended to click it...
3
by: Paul | last post by:
Hi all, I've been trying unsuccessfully to stop client side event validation. I've created a simple page with a text box, a required field validator and a server button with the following...
2
by: Thomas Guignard | last post by:
Hi there I need to run an XSLT stylesheet on XML files generated by another app that seem to have errors. When I try to run my XSLT processor (MSXML engine, run through the Cooktop editor), I...
3
by: John Grandy | last post by:
Does anyone have experience with turning off ASP.NET event validation ? What is the complete set of consequences ? I'm aware that event validation ensures that parameter values submitted to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.