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

validation doesn't fire


validation doesn't fire

what's missing ?????
/////// ---- code -----///////////////////////////
Sub btnSubmit_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) 'Handles btnSubmit.Click
If page.isValid then
.....
end if
//////// --form --- ///////////////////////
<asp:TextBox id="x_Card_Num" runat="server" Width="250px"></asp:TextBox>
<asp:RequiredFieldValidator ID="x_Card_NumRequired" runat="server"
ControlToValidate="x_Card_Num"
ErrorMessage=""

ValidationGroup="orderform">*</asp:RequiredFieldValidator>

.....

<asp:validationSummary id="summary" runat="server"
ValidationGroup="orderform"
ShowmessageBox="False"
ShowSummary="True"
DisplayMode ="BulletList" />

<asp:ImageButton ID="btnSubmit" runat="server"
BorderWidth="0"
onclick="btnSubmit_Click"
ImageUrl="~/images/continue.gif" />
Jan 31 '07 #1
6 3323
2 Things I see...

1. Your "Handles" clause on the btnSubmit event handler is commented so
there is a chance that this procedure isn't even being executed.
2. You don't need to write any code at all to get the
RequiredFieldValidator to work and usually don't need to check for
Page.IsValid because the client and server side validations would prevent
the page from processing.

"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot comwrote in message
news:u1**************@TK2MSFTNGP06.phx.gbl...
>
validation doesn't fire

what's missing ?????
/////// ---- code -----///////////////////////////
Sub btnSubmit_Click(sender As Object, e As
System.Web.UI.ImageClickEventArgs) 'Handles btnSubmit.Click
If page.isValid then
.....
end if
//////// --form --- ///////////////////////
<asp:TextBox id="x_Card_Num" runat="server" Width="250px"></asp:TextBox>
<asp:RequiredFieldValidator ID="x_Card_NumRequired" runat="server"
ControlToValidate="x_Card_Num"
ErrorMessage=""

ValidationGroup="orderform">*</asp:RequiredFieldValidator>

....

<asp:validationSummary id="summary" runat="server"
ValidationGroup="orderform"
ShowmessageBox="False"
ShowSummary="True"
DisplayMode ="BulletList" />

<asp:ImageButton ID="btnSubmit" runat="server"
BorderWidth="0"
onclick="btnSubmit_Click"
ImageUrl="~/images/continue.gif" />

Jan 31 '07 #2
1. Your "Handles" clause on the btnSubmit event handler is commented so there is a chance that this procedure isn't even being
executed.
fortunately, other items in the procedure are working so I know the procedure is being processed....

2. You don't need to write any code at all to get the RequiredFieldValidator to work and usually don't need to check for
Page.IsValid because the client and server side validations would prevent the page from processing.
I guess that's where I'm stuck.
They're not firing ...The page goes through and ignores the required fields

>
"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot comwrote in message news:u1**************@TK2MSFTNGP06.phx.gbl...
>>
validation doesn't fire

what's missing ?????
/////// ---- code -----///////////////////////////
Sub btnSubmit_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) 'Handles btnSubmit.Click
If page.isValid then
.....
end if
//////// --form --- ///////////////////////
<asp:TextBox id="x_Card_Num" runat="server" Width="250px"></asp:TextBox>
<asp:RequiredFieldValidator ID="x_Card_NumRequired" runat="server"
ControlToValidate="x_Card_Num"
ErrorMessage=""

ValidationGroup="orderform">*</asp:RequiredFieldValidator>

....

<asp:validationSummary id="summary" runat="server"
ValidationGroup="orderform"
ShowmessageBox="False"
ShowSummary="True"
DisplayMode ="BulletList" />

<asp:ImageButton ID="btnSubmit" runat="server"
BorderWidth="0"
onclick="btnSubmit_Click"
ImageUrl="~/images/continue.gif" />


Jan 31 '07 #3
If the validator is in "orderform" validation group, the Button should be in
the same group also? E.g it should also have
ValidationGroup="orderform"?

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot comwrote in message
news:uv**************@TK2MSFTNGP03.phx.gbl...
>
>1. Your "Handles" clause on the btnSubmit event handler is commented so
there is a chance that this procedure isn't even being executed.

fortunately, other items in the procedure are working so I know the
procedure is being processed....

>2. You don't need to write any code at all to get the
RequiredFieldValidator to work and usually don't need to check for
Page.IsValid because the client and server side validations would prevent
the page from processing.

I guess that's where I'm stuck.
They're not firing ...The page goes through and ignores the required
fields

>>
"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot comwrote in message
news:u1**************@TK2MSFTNGP06.phx.gbl...
>>>
validation doesn't fire

what's missing ?????
/////// ---- code -----///////////////////////////
Sub btnSubmit_Click(sender As Object, e As
System.Web.UI.ImageClickEventArgs) 'Handles btnSubmit.Click
If page.isValid then
.....
end if
//////// --form --- ///////////////////////
<asp:TextBox id="x_Card_Num" runat="server"
Width="250px"></asp:TextBox>
<asp:RequiredFieldValidator ID="x_Card_NumRequired" runat="server"
ControlToValidate="x_Card_Num"
ErrorMessage=""

ValidationGroup="orderform">*</asp:RequiredFieldValidator>

....

<asp:validationSummary id="summary" runat="server"
ValidationGroup="orderform"
ShowmessageBox="False"
ShowSummary="True"
DisplayMode ="BulletList" />

<asp:ImageButton ID="btnSubmit" runat="server"
BorderWidth="0"
onclick="btnSubmit_Click"
ImageUrl="~/images/continue.gif" />


Jan 31 '07 #4
Page.IsValid is the key to check in case client misses the client-side
validation. That's the server-side stop to prevent code from running if
validation fails at server-side.

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"Scott M." <s-***@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>2 Things I see...

1. Your "Handles" clause on the btnSubmit event handler is commented so
there is a chance that this procedure isn't even being executed.
2. You don't need to write any code at all to get the
RequiredFieldValidator to work and usually don't need to check for
Page.IsValid because the client and server side validations would prevent
the page from processing.

"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot comwrote in message
news:u1**************@TK2MSFTNGP06.phx.gbl...
>>
validation doesn't fire

what's missing ?????
/////// ---- code -----///////////////////////////
Sub btnSubmit_Click(sender As Object, e As
System.Web.UI.ImageClickEventArgs) 'Handles btnSubmit.Click
If page.isValid then
.....
end if
//////// --form --- ///////////////////////
<asp:TextBox id="x_Card_Num" runat="server" Width="250px"></asp:TextBox>
<asp:RequiredFieldValidator ID="x_Card_NumRequired" runat="server"
ControlToValidate="x_Card_Num"
ErrorMessage=""

ValidationGroup="orderform">*</asp:RequiredFieldValidator>

....

<asp:validationSummary id="summary" runat="server"
ValidationGroup="orderform"
ShowmessageBox="False"
ShowSummary="True"
DisplayMode ="BulletList" />

<asp:ImageButton ID="btnSubmit" runat="server"
BorderWidth="0"
onclick="btnSubmit_Click"
ImageUrl="~/images/continue.gif" />

Jan 31 '07 #5
The default action is to do server-side validation as well, for just this
reason. There is no need to check for Page.IsValid on standard validation
controls.
"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:52**********************************@microsof t.com...
Page.IsValid is the key to check in case client misses the client-side
validation. That's the server-side stop to prevent code from running if
validation fails at server-side.

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"Scott M." <s-***@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>2 Things I see...

1. Your "Handles" clause on the btnSubmit event handler is commented so
there is a chance that this procedure isn't even being executed.
2. You don't need to write any code at all to get the
RequiredFieldValidator to work and usually don't need to check for
Page.IsValid because the client and server side validations would prevent
the page from processing.

"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot comwrote in message
news:u1**************@TK2MSFTNGP06.phx.gbl...
>>>
validation doesn't fire

what's missing ?????
/////// ---- code -----///////////////////////////
Sub btnSubmit_Click(sender As Object, e As
System.Web.UI.ImageClickEventArgs) 'Handles btnSubmit.Click
If page.isValid then
.....
end if
//////// --form --- ///////////////////////
<asp:TextBox id="x_Card_Num" runat="server"
Width="250px"></asp:TextBox>
<asp:RequiredFieldValidator ID="x_Card_NumRequired" runat="server"
ControlToValidate="x_Card_Num"
ErrorMessage=""

ValidationGroup="orderform">*</asp:RequiredFieldValidator>

....

<asp:validationSummary id="summary" runat="server"
ValidationGroup="orderform"
ShowmessageBox="False"
ShowSummary="True"
DisplayMode ="BulletList" />

<asp:ImageButton ID="btnSubmit" runat="server"
BorderWidth="0"
onclick="btnSubmit_Click"
ImageUrl="~/images/continue.gif" />


Jan 31 '07 #6
Yes, it does validate but you do need to check Page.IsValid (or specific
validator's IsValid) to see if it passed or not (no one does that for you)
if you want to be 100% sure nothing gets pass the validation. That is, you
cannot rely solely on client-side validation.

Consider this example (TextBox, a couple of validators and a Button plus
Label):

<asp:TextBox ID="txtExpectingIntegers" runat="server" />
<asp:RequiredFieldValidator ID="reqINteger" runat="server"
ControlToValidate="txtExpectingIntegers" ErrorMessage="Insert something!" />
<asp:CompareValidator ID="cmpValInt" runat="server"
ControlToValidate="txtExpectingIntegers" Operator="DataTypeCheck"
Type="Integer" ErrorMessage="Please enter an integer!" />
<asp:Button ID="btnSend" runat="server" Text="Try it out"
OnClick="btnSend_Click" />

<asp:Label ID="lblMessage" runat="server" />

// Code

protected void btnSend_Click(object sender, EventArgs e)
{
//Testing for Page.IsValid here helps...
// if(!Page.IsValid)return;

try
{
int val = Int32.Parse(txtExpectingIntegers.Text);
lblMessage.Text ="We got an integer " + val.ToString();
}
catch(Exception ex)
{
lblMessage.Text = "Exception while parsing the integer:" +
ex.ToString();
}
}
If you now open it in in any normal browser with js enabled, of course with
standard scripts enabled it's catched & validated. But go now and disable
javascripts in your browser. Then type something non-number to the TextBox
and you'll see it blow, as Button's click is handled normally as if there
would be no validation. E.g nothing prevents the Button's click event from
running unless *you* check for the outcome of the validation (validation
message are displayed but page executes as-is). Think if it would be a
database operation dependant on the input user enters...

So to summarize: you do want to check IsValid at the server. Just running
validation isn't enough, you do need to know did it pass or not to decide
what's next (to let ValidationSummary display a nice message)

In case you don't still believe me, see this one:
http://msdn2.microsoft.com/en-us/library/7kh55542.aspx

There's this sentence

"ASP.NET performs validation on the server even if the validation controls
have already performed it on the client, so that you can test for validity
within your server-based event handlers. In addition, re-testing on the
server helps prevent users from being able to bypass validation by disabling
or changing the client script check."

Of course in normal intranet scenario these probably aren't issues, but I'd
think that being sure isn't too bad choice.

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net



"Scott M." <s-***@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
The default action is to do server-side validation as well, for just this
reason. There is no need to check for Page.IsValid on standard validation
controls.
"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:52**********************************@microsof t.com...
>Page.IsValid is the key to check in case client misses the client-side
validation. That's the server-side stop to prevent code from running if
validation fails at server-side.

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"Scott M." <s-***@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>>2 Things I see...

1. Your "Handles" clause on the btnSubmit event handler is commented so
there is a chance that this procedure isn't even being executed.
2. You don't need to write any code at all to get the
RequiredFieldValidator to work and usually don't need to check for
Page.IsValid because the client and server side validations would
prevent the page from processing.

"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot comwrote in message
news:u1**************@TK2MSFTNGP06.phx.gbl...

validation doesn't fire

what's missing ?????
/////// ---- code -----///////////////////////////
Sub btnSubmit_Click(sender As Object, e As
System.Web.UI.ImageClickEventArgs) 'Handles btnSubmit.Click
If page.isValid then
.....
end if
//////// --form --- ///////////////////////
<asp:TextBox id="x_Card_Num" runat="server"
Width="250px"></asp:TextBox>
<asp:RequiredFieldValidator ID="x_Card_NumRequired" runat="server"
ControlToValidate="x_Card_Num"
ErrorMessage=""

ValidationGroup="orderform">*</asp:RequiredFieldValidator>

....

<asp:validationSummary id="summary" runat="server"
ValidationGroup="orderform"
ShowmessageBox="False"
ShowSummary="True"
DisplayMode ="BulletList" />

<asp:ImageButton ID="btnSubmit" runat="server"
BorderWidth="0"
onclick="btnSubmit_Click"
ImageUrl="~/images/continue.gif" />

Feb 1 '07 #7

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

Similar topics

7
by: Tom | last post by:
I know how to use these great controls. They work very well. But is there a method or property I can use to set the focus to the field that is in error. For example... If I have a page with 5...
6
by: Nedu N | last post by:
Hi, I want to have confirmation(Yes/No) on a button of the webform in which there are many validation controls. I want all the validation controls to be triggered first and then Yes/No...
1
by: Arpan | last post by:
I have a Web Form in my ASPX page which makes use of Web controls & incorporates validation controls. This is the code snippet that does the needful: <form runat=server> NAME:<asp:TextBox...
1
by: MattC | last post by:
I have a user control that contains several requiredFieldValidators. The page the control sits in has other RequiredFieldValidators. On submitting the form all the validators on the page fire and...
45
by: Pat | last post by:
its seems asp.net validation doesn't fire when using FireFox? Tested a page and it doesn't fire. It seems the javascript doesn't fire Any ideas?
9
by: Bill Long | last post by:
I have a control that simply displays a list of links. Following one of the links doesn't post back or redirect to another page, it simply hides the current panel and shows the one you selected......
22
by: Charles Law | last post by:
Could someone please explain to me, in words of one syllable or less, how I get the Validating event to fire for a form. I have a form with one text box, and two buttons: OK and Cancel. I have...
2
by: winnie_us99 | last post by:
Hi All, I am trying to do validation on my text field before going to the next page to create a user. It doesn't look like the next button will fire any validation. Am I missing something? Can...
1
by: misiek | last post by:
Hi all. I have following problem: I have some user control called smallUserContrl, in which I have two RangeValidator controls. I set their ValidationGroup property to smallUserControlGroup. ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
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...

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.