473,597 Members | 2,459 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2412
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 CausesValidatio n 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
CausesValidatio n=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****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

<in*******@hotm ail.com> wrote in message
news:a8******** *************** **@posting.goog le.com...
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.IsPostB ack != true)
{
Globals.Account = true;
Globals.Navigat ion(this, Globals.Paramet er(this, "mi"),
Globals.Paramet er(this, "si"), Globals.Paramet er(this, "ni"),
Globals.Paramet er(this, "ln"));
this.CurrentCul ture =
System.Globaliz ation.CultureIn fo.CreateSpecif icCulture(Sessi on["Language"].ToString());
Browser.Accept = "text/*";
Menuloader(null );
Traductor(null) ;
Visualization(n ull);
RightPane.Contr ols.Add(Page.Lo adControl("~/controls/search.ascx"));
string win = "false";
Rx.Attributes.R emove("onsubmit ");
Page.RegisterHi ddenField("__EV ENTTARGET", "Submit");
Rx.Attributes.A dd("onsubmit"," javascript: validation("+ win +");");
}
Session["UrlRedirec t"] = Request.Url.ToS tring();
Enrique.
<in*******@hotm ail.com> wrote in message
news:a8******** *************** **@posting.goog le.com...
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
5472
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 should be presented with two buttons a "Submit" and a "Cancel". When the "Cancel" button is selected all of the items on the user control should be cleared. However, I have validation controls setup for each item necessary on the form and when...
14
6283
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) show the error message next to the control. For example, if the text field is empty with RequiredField Validator control, it can show the value in ControlToValidate property in two ways as I mentioned. Please advise. Thanks!
4
10137
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 the validators. The user enters the data, presses OK. My OK button is dynamically generated as well, with some code-behind logic in
1
3249
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 other input fields available to fill in. I use the JavaScript OnChange function (=clientside) that creates a querystring and does a refresh of the page. It works fine.
1
1510
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 click event. -The Datagrids onitemdatabound event dynamically creates validation controls per values from other columns in the datagrid, one of those controls is a textbox and it is the ControlToValidate of the validation control.
0
2939
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 such as when they do a delete. Everything is great. By and large it will be used in my repeater controls using the command event when the user clicks on it and so that event is working great. My issue is the Click event. When the control is...
3
3026
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 settings: 1. <pages enableEventValidation="false"in web.config 2. EnableClientScript="false" in the required field validator. 3. EnableEventValidation="false" in the Page directive (which, I know, is not necessary).
2
2720
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 get the following error message ERROR: pattern constraint failed. The element: '{http://www.loc.gov/MARC21/slim}leader' has an invalid value according to its data type.
3
5932
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 event handlers for read-only ASP.NET web controls ( such as ListBox ) must match the list of possible values available at the time the control is rendered on the server; non-matching values will trigger a runtime exception. Turning off event...
0
7971
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8381
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8040
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8259
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3889
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2408
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1495
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1243
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.