473,320 Members | 1,713 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,320 software developers and data experts.

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 3828
"Mike Chen" <ch****@gmail.comwrote in message
news:%2***************@TK2MSFTNGP06.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**@markNOSPAMrae.comwrote in message
news:ej****************@TK2MSFTNGP04.phx.gbl...
"Mike Chen" <ch****@gmail.comwrote in message
news:%2***************@TK2MSFTNGP06.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:RequiredFieldValidator runat="server" ID="rfvName"
ControlToValidate="txtName" ErrorMessage="Got ya!" EnableClientScript="true"/>
<asp:Button runat="server" ID="btnSubmit" CausesValidation="false"
Text="Submit!" OnClientClick="return ValidateOrShowDialogBox2()"/>

<script type="text/javascript">
// example that checks particular validator
function ValidateOrShowDialogBox()
{
var validator = document.getElementById('<%=rfvName.ClientID %>');

ValidatorValidate(validator);

// you can use Page_Validators array instead
if (validator.isvalid)
{
// 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 ValidateOrShowDialogBox2()
{
var validator;

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

// validation fails if at least one validator fails
if (!validator.isvalid)
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 ValidationSummary 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.comwrote in message
news:%2***************@TK2MSFTNGP06.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*****@REMOVEITwp.plwrote in message
news:4A**********************************@microsof t.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*****@REMOVEITwp.plwrote in message
news:4A**********************************@microsof t.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
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...
4
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...
3
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...
3
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...
1
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...
6
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...
2
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...
2
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...
1
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.