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 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
"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
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
"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 >> >> > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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,...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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
|
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...
| |