473,320 Members | 2,094 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.

Fire Custom Validator on AutoPostback

I am trying to fire the CustomValidator when I leave the Email field.
Following is the code. It does PostBack, but the CustomValidator doesn't
seem to be firing.

<asp:TextBox AutoPostBack="true" Columns="45" ID="email"
runat="server" TextMode="SingleLine" />
<asp:CustomValidator
ControlToValidate="email"
OnServerValidate="ValidateEmail"
Font-Size="10"
Display="Dynamic"
Text="Not Valid !"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="email"
Text="Email Required"
runat="server" />
<asp:RegularExpressionValidator ControlToValidate="email" Text =
"Invalid Email Address!"
ValidationExpression="\S+@\S+\.\S{2,3}" runat="server" />

What tells it to execute?

Thanks,

Tom
Nov 19 '05 #1
4 8862
Tshad,
You need to manually fire off the server-side validation process with
Page.Validate() From your example, this would likely be something like:

Private Sub email_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles email.TextChanged
Page.Validate()
If Page.IsValid Then
'stuf here
End If
End Sub
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/index.aspx - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"tshad" <ts**********@ftsolutions.com> wrote in message
news:e4**************@TK2MSFTNGP14.phx.gbl...
I am trying to fire the CustomValidator when I leave the Email field.
Following is the code. It does PostBack, but the CustomValidator doesn't
seem to be firing.

<asp:TextBox AutoPostBack="true" Columns="45" ID="email"
runat="server" TextMode="SingleLine" />
<asp:CustomValidator
ControlToValidate="email"
OnServerValidate="ValidateEmail"
Font-Size="10"
Display="Dynamic"
Text="Not Valid !"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="email"
Text="Email Required"
runat="server" />
<asp:RegularExpressionValidator ControlToValidate="email" Text =
"Invalid Email Address!"
ValidationExpression="\S+@\S+\.\S{2,3}" runat="server" />

What tells it to execute?

Thanks,

Tom

Nov 19 '05 #2
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:Ot**************@tk2msftngp13.phx.gbl...
Tshad,
You need to manually fire off the server-side validation process with
Page.Validate() From your example, this would likely be something like:

Private Sub email_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles email.TextChanged
Page.Validate()
If Page.IsValid Then
'stuf here
End If
End Sub

How do I prevent it from firing when I push a button (as it would already
have been done from the autopost)?

If I have 3 buttons on my screen, does it get executed regardless of which
button is pushed?

Thanks,

Tom
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/index.aspx - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"tshad" <ts**********@ftsolutions.com> wrote in message
news:e4**************@TK2MSFTNGP14.phx.gbl...
I am trying to fire the CustomValidator when I leave the Email field.
Following is the code. It does PostBack, but the CustomValidator doesn't
seem to be firing.

<asp:TextBox AutoPostBack="true" Columns="45" ID="email"
runat="server" TextMode="SingleLine" />
<asp:CustomValidator
ControlToValidate="email"
OnServerValidate="ValidateEmail"
Font-Size="10"
Display="Dynamic"
Text="Not Valid !"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="email"
Text="Email Required"
runat="server" />
<asp:RegularExpressionValidator ControlToValidate="email" Text =
"Invalid Email Address!"
ValidationExpression="\S+@\S+\.\S{2,3}" runat="server" />

What tells it to execute?

Thanks,

Tom


Nov 19 '05 #3
It gets executed wherever you put Page.Validate() so if you put it in the
event of each control and check for Page.IsValid then it'll execute in all
three. If you only put it in a single event, then it'll only happen
there...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/index.aspx - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:Ot**************@tk2msftngp13.phx.gbl...
Tshad,
You need to manually fire off the server-side validation process with
Page.Validate() From your example, this would likely be something like:

Private Sub email_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles email.TextChanged
Page.Validate()
If Page.IsValid Then
'stuf here
End If
End Sub


How do I prevent it from firing when I push a button (as it would already
have been done from the autopost)?

If I have 3 buttons on my screen, does it get executed regardless of which
button is pushed?

Thanks,

Tom

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/index.aspx - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"tshad" <ts**********@ftsolutions.com> wrote in message
news:e4**************@TK2MSFTNGP14.phx.gbl...
I am trying to fire the CustomValidator when I leave the Email field.
Following is the code. It does PostBack, but the CustomValidator doesn't seem to be firing.

<asp:TextBox AutoPostBack="true" Columns="45" ID="email"
runat="server" TextMode="SingleLine" />
<asp:CustomValidator
ControlToValidate="email"
OnServerValidate="ValidateEmail"
Font-Size="10"
Display="Dynamic"
Text="Not Valid !"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="email"
Text="Email Required"
runat="server" />
<asp:RegularExpressionValidator ControlToValidate="email" Text =
"Invalid Email Address!"
ValidationExpression="\S+@\S+\.\S{2,3}" runat="server" />

What tells it to execute?

Thanks,

Tom



Nov 19 '05 #4
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:Oi**************@tk2msftngp13.phx.gbl...
It gets executed wherever you put Page.Validate() so if you put it in
the
event of each control and check for Page.IsValid then it'll execute in all
three. If you only put it in a single event, then it'll only happen
there...
I don't have Page.Validate() anywhere in my code and it still fires.

Tom
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/index.aspx - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:Ot**************@tk2msftngp13.phx.gbl...
> Tshad,
> You need to manually fire off the server-side validation process with
> Page.Validate() From your example, this would likely be something
> like:
>
> Private Sub email_TextChanged(ByVal sender As System.Object, ByVal e
> As
> System.EventArgs) Handles email.TextChanged
> Page.Validate()
> If Page.IsValid Then
> 'stuf here
> End If
> End Sub
>


How do I prevent it from firing when I push a button (as it would already
have been done from the autopost)?

If I have 3 buttons on my screen, does it get executed regardless of
which
button is pushed?

Thanks,

Tom
>
> Karl
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/index.aspx - New and Improved (yes, the popup is > annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
>
>
> "tshad" <ts**********@ftsolutions.com> wrote in message
> news:e4**************@TK2MSFTNGP14.phx.gbl...
>> I am trying to fire the CustomValidator when I leave the Email field.
>> Following is the code. It does PostBack, but the CustomValidator doesn't >> seem to be firing.
>>
>> <asp:TextBox AutoPostBack="true" Columns="45" ID="email"
>> runat="server" TextMode="SingleLine" />
>> <asp:CustomValidator
>> ControlToValidate="email"
>> OnServerValidate="ValidateEmail"
>> Font-Size="10"
>> Display="Dynamic"
>> Text="Not Valid !"
>> runat="server" />
>> <asp:RequiredFieldValidator
>> ControlToValidate="email"
>> Text="Email Required"
>> runat="server" />
>> <asp:RegularExpressionValidator ControlToValidate="email" Text
>> =
>> "Invalid Email Address!"
>> ValidationExpression="\S+@\S+\.\S{2,3}" runat="server" />
>>
>> What tells it to execute?
>>
>> Thanks,
>>
>> Tom
>>
>>
>
>



Nov 19 '05 #5

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

Similar topics

2
by: Dot net work | last post by:
Hello. If I use an asp.net custom validator control to validate a textbox, what I find is that if I enter in some text that I have already entered and validated in a previous session (you know...
10
by: Rigs | last post by:
Hi, I have a textbox with a Custom Validator that utilizes the OnServerValidate method for that textbox. This works fine, however the method only executes when data exists in that textbox after...
5
by: Richard Payne | last post by:
Hi This is probably a newbie question but I can't seem to find a clear answer to the problem I have. I have created a Custom Validator control on my webform that works fine, but when I put...
9
by: Alex Shirley | last post by:
Hi there I’m simply trying to check for a blank or empty value in a textbox on my webform. In this instance I do not want to use a requiredfieldvalidator, I want to use a customvalidator (as I...
1
by: Ben | last post by:
i'm having trouble getting a custom validator to fire on one of my webforms. i dragged a custom validator onto the form, left all the properties on default, double clicked it, and typed this in the...
1
by: Tarun Mistry | last post by:
Hi there everyone, I have a page containing dynamic user controls. The main page contains a custom validator that checks the dynamic user controls, this works fine. However, I only want the...
3
by: Andy | last post by:
Hi folks, I have a customvalidator control that works properly if it isn't contained in an ASP:TABLE. But, when I place it inside an ASP:TABLE, I find that _ServerValidate doesn't get fired,...
3
by: Rich Squid | last post by:
Hello Here's my basic problem: On my asp.net form page I have a DetailsView (default mode=edit) bound to a AccessDataSource control. Users can successfuly update a databound template field,...
0
by: mayankagarwal | last post by:
Over the last few days i have read a lot of forum about custom validator not working or not firing etc. I am stuck in a similar situation and of all the solutions i have come across they dont seem to...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.