473,659 Members | 3,239 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

is there a way to perform a client side kind of Page.IsValid validation?

We know in server code, we can check the page validated by using
Page.IsValid where we put some validator controls on aspx page.
I want to set some value after validating user input values on client
side and before page posts to server. How can i get the functionality of
client side Page.IsValid? thanks.
Jan 28 '07 #1
6 3851
"Mike Chen" <ch****@gmail.c omwrote in message
news:%2******** *******@TK2MSFT NGP06.phx.gbl.. .
We know in server code, we can check the page validated by using
Page.IsValid where we put some validator controls on aspx page.
I want to set some value after validating user input values on client side
and before page posts to server. How can i get the functionality of client
side Page.IsValid? thanks.
I have my own set of JavaScript routines for this.

I don't use the validator controls at all, unless I absolutely have to (e.g.
for custom controls), as I find them incredibly cumbersome and restrictive.
Jan 28 '07 #2
ditto

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:ej******** ********@TK2MSF TNGP04.phx.gbl. ..
"Mike Chen" <ch****@gmail.c omwrote in message
news:%2******** *******@TK2MSFT NGP06.phx.gbl.. .
>We know in server code, we can check the page validated by using
Page.IsValid where we put some validator controls on aspx page.
I want to set some value after validating user input values on client
side and before page posts to server. How can i get the functionality of
client side Page.IsValid? thanks.

I have my own set of JavaScript routines for this.

I don't use the validator controls at all, unless I absolutely have to
(e.g. for custom controls), as I find them incredibly cumbersome and
restrictive.

Jan 28 '07 #3
Hi Mark and Mike,

Of course there is. ASP.NET provides nice client side API to support custom,
non standard scenarios. In addtion to that Mark, there is no need for coding
such functionality on your own as provided API can solve 99% cases. Let me
give you a simple example how to validate the page youself using client side
API:

<asp:TextBox runat="server" ID="txtName"/>
<asp:RequiredFi eldValidator runat="server" ID="rfvName"
ControlToValida te="txtName" ErrorMessage="G ot ya!" EnableClientScr ipt="true"/>
<asp:Button runat="server" ID="btnSubmit" CausesValidatio n="false"
Text="Submit!" OnClientClick=" return ValidateOrShowD ialogBox2()"/>

<script type="text/javascript">
// example that checks particular validator
function ValidateOrShowD ialogBox()
{
var validator = document.getEle mentById('<%=rf vName.ClientID %>');

ValidatorValida te(validator);

// you can use Page_Validators array instead
if (validator.isva lid)
{
// create dialog box here
alert('well done!');
}
// set it to true to post back page
return false;
}

// example that checks all validators on the page
function ValidateOrShowD ialogBox2()
{
var validator;

for (var i = 0; i < Page_Validators .length; i++)
{
validator = Page_Validators[i];
ValidatorValida te(validator);

// validation fails if at least one validator fails
if (!validator.isv alid)
return false;
}

// create dialog box here
alert('well done!');

// set it to true to post back page
return false;
}

</script>

One more thing. You may apply several validators to the same control (in
conjunction with ValidationSumma ry control and/or Display property of the
validator) which is a quick and efficient way of building validation chain.

Regards guys
--
Milosz
"Mark Rae" wrote:
"Mike Chen" <ch****@gmail.c omwrote in message
news:%2******** *******@TK2MSFT NGP06.phx.gbl.. .
We know in server code, we can check the page validated by using
Page.IsValid where we put some validator controls on aspx page.
I want to set some value after validating user input values on client side
and before page posts to server. How can i get the functionality of client
side Page.IsValid? thanks.

I have my own set of JavaScript routines for this.

I don't use the validator controls at all, unless I absolutely have to (e.g.
for custom controls), as I find them incredibly cumbersome and restrictive.
Jan 28 '07 #4
"Milosz Skalecki [MCAD]" <mi*****@REMOVE ITwp.plwrote in message
news:4A******** *************** ***********@mic rosoft.com...
Of course there is.
I didn't say there wasn't...
In addtion to that Mark, there is no need for coding such functionality on
your own
Yes there is - the need is the fact that that's the way I choose to do it...
Let me give you a simple example
ROTFLMAO!!! And that's *precisely* why I roll my own validation - thanks
very much , you really made my day...:-)
Jan 29 '07 #5
Mark,

don't take it personally ;-) My reply is based on Mike's question and your
reply - you didn't mention validation api so i simply thought you didn't know
too.

--
Milosz
"Mark Rae" wrote:
"Milosz Skalecki [MCAD]" <mi*****@REMOVE ITwp.plwrote in message
news:4A******** *************** ***********@mic rosoft.com...
Of course there is.

I didn't say there wasn't...
In addtion to that Mark, there is no need for coding such functionality on
your own

Yes there is - the need is the fact that that's the way I choose to do it...
Let me give you a simple example

ROTFLMAO!!! And that's *precisely* why I roll my own validation - thanks
very much , you really made my day...:-)
Jan 29 '07 #6
Milosz Skalecki [MCAD] wrote:
Mark,

don't take it personally ;-) My reply is based on Mike's question and your
reply - you didn't mention validation api so i simply thought you didn't know
too.
Thanks Milosz, it did work fine for me.
Jan 29 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1264
by: Gareth | last post by:
Hi, I've just published a test web site on the internet with a simple form and some client side validation controls. On my development PC if I click submit without entering any data the validation controls work and prompt me as expected. On the live web server I do exactly the same thing but no validation is performed and the form is submitted. How can this be? Have I missed something in the setup script? I added both the primary...
4
2365
by: | last post by:
Hello Guys, I am using the validation controls to validate my data. But the problem is "The page is still being posted to server". I want to get rid of the round trips to server. Are there any get arounds for this problem apart from the traditional JavaScript?
3
13132
by: Earl Teigrob | last post by:
I wanted my "Terms and Conditions" Checkbox control to participate in my ASP.NET validation just like all the the other controls on the page. After some time of searching the web for an example of how to do this, I created the script to do it and thought I would share it. Its a littel messy but does the job. If anyone has a better solution, please let me know. //Client Site Event Handler to put in Page_Load event...
3
2189
by: Lisa Calla | last post by:
Hi, I've been struggling with this for a few days. I've seen bits and pieces (how to set up custom validation), but I can't seem to understand how to get client side validation for my custom composite control (the textbox part). I've done a ton of vbnet, am new to aspnet, but barely know how to spell java. Anyone know of a good website or tutorial for this kind of thing? TIA
1
5222
by: rmgalante | last post by:
I have written an ASP.Net application that uses the standard client-side and server-side validation for various fields on the form. Some of the customers that use the form report symptoms that appear to be the result of double-clicking the submit button on the form. The form has three ASP:Button tags, each of which gets translated into INPUT TYPE="SUBMIT" HTML elements. One submits the form's data. One logs the user out. And the other...
6
1287
by: Ben Fidge | last post by:
Hi I'm interested to know what peoples opinions are on using the Client-side Validators in ASP.NET? I use them very heavily but am experiencing the odd occassion when users have either intentionally or inadvertantly bipassed them. Any ideas on how this could happen. I know that a determined hacker can push data into http context and viewstate. But other than that, would disabling javascript in the browser allow a user to bipass...
2
1401
by: Fabrice | last post by:
Hello, For security reasons, i'd like to permit validation on client and server side. But if JavaScript is desactivate on the client, the validation have to take place on server side for catch page.isvalid property. How to do that ? by this way :
2
1789
by: Alan Silver | last post by:
Hello, I have a custom validator on my page, and have the server-side code working fine. I want to add a client-side funtion as well, but am not sure how to wire it in so that it works with the other validators on the page. I specified the name of the Javascript function with the ClientValidationFunction attribute of the custom validator, and it is being called fine. However, if the validator returns false (ie bad
1
3939
by: Hong Hao | last post by:
Recently, I was trying to modify an existing aspx page when client-side validation on that page stopped working. I searched this group and the web in general and found that other people have had the same issue. However, none of the suggested fixes solved my particular problem. I tracked down the cause of the problem, which is related to aspx page parser's handling of controls inside html comments. The problem may be quite common and well...
0
8428
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
8335
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8747
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
8528
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
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
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
4175
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
2752
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
2
1737
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.