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

RequiredFieldValidator failed?

Hi,

I have a Asp.Net written in C#. It serve as information input form. The form encounters sort of
random problem with the email field and state field. I have validator attached with these 2 fields
as the following:
=====
<form id="creditcardform" method="post" runat="server">
Email: <asp:textbox id="txtBillEmail" maxlength="50" width="200" runat="server" />
<asp:requiredfieldvalidator id="vp10" runat="server" initialvalue=""
controltovalidate="txtBillEmail" errormessage="Billing Email cannot be empty" />
<asp:regularexpressionvalidator id="vp11" runat="server" controltovalidate="txtBillEmail"
errormessage="Billing Email must follow em***@host.domain"
validationexpression="^.+\@.+\..+$" display="Dynamic" />

State: <asp:dropdownlist id="lstBillState" runat="server" />
<asp:requiredfieldvalidator id="vp7" runat="server" initialvalue=""
controltovalidate="lstBillState"
errormessage="Billing State must select one" display="Dynamic" />

<asp:button id="btnSubmit" causesvalidation="True" text="Submit" runat="server" cssclass="button" />
</form>
=====

My understanding is that the <asp:requiredfieldvalidator> should guarantee the value of the field when the value of
"causesvalidation" sets to "True" in the submit button. But what happened was that no error was generated when "btnSubmit" was clicked, but the value of one of these 2 fields get lost in the codebehind file. I tried to catch it on our development server, but I've never caught it. It only occurs on our production server. This problem doesn't always occur.
It only happens once a while randomly.

Would you please help me to figure out the cause of such value loss?

Thank you

hb
Nov 19 '05 #1
2 2065
Both the regular expression and custom validators do not perform
client-side or server-side validation when no value is entered into the
control that is set for the validators' "ControlToValidate" properties.
This is by design.

Maybe that's what is causing it???
Hongbo wrote:
Hi,

I have a Asp.Net written in C#. It serve as information input form. The form encounters sort of
random problem with the email field and state field. I have validator attached with these 2 fields
as the following:
=====
<form id="creditcardform" method="post" runat="server">
Email: <asp:textbox id="txtBillEmail" maxlength="50" width="200" runat="server" />
<asp:requiredfieldvalidator id="vp10" runat="server" initialvalue=""
controltovalidate="txtBillEmail" errormessage="Billing Email cannot be empty" />
<asp:regularexpressionvalidator id="vp11" runat="server" controltovalidate="txtBillEmail"
errormessage="Billing Email must follow em***@host.domain"
validationexpression="^.+\@.+\..+$" display="Dynamic" />

State: <asp:dropdownlist id="lstBillState" runat="server" />
<asp:requiredfieldvalidator id="vp7" runat="server" initialvalue=""
controltovalidate="lstBillState"
errormessage="Billing State must select one" display="Dynamic" />

<asp:button id="btnSubmit" causesvalidation="True" text="Submit" runat="server" cssclass="button" />
</form>
=====

My understanding is that the <asp:requiredfieldvalidator> should guarantee the value of the field when the value of
"causesvalidation" sets to "True" in the submit button. But what happened was that no error was generated when "btnSubmit" was clicked, but the value of one of these 2 fields get lost in the codebehind file. I tried to catch it on our development server, but I've never caught it. It only occurs on our production server. This problem doesn't always occur.
It only happens once a while randomly.

Would you please help me to figure out the cause of such value loss?

Thank you

hb


Nov 19 '05 #2
Hi, Joey,

Thank you for helping me.

I have ASP:RequiredFieldValidator attached with both TextBox and
DropdownList.
My understanding is that ASP:RequiredFieldValidator should prevent the
submit
button click to go any further if either of the controls contains no value.

But the fact was that the button click event did fire without error. What I
guess is that
the user might input value in these 2 controls and that the value get lost
somehow
when the button click event tried to retrieve value from these control in
CodeBehind.

But how could that happen?
"Joey" <jo*********@topscene.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Both the regular expression and custom validators do not perform
client-side or server-side validation when no value is entered into the
control that is set for the validators' "ControlToValidate" properties.
This is by design.

Maybe that's what is causing it???
Hongbo wrote:
Hi,

I have a Asp.Net written in C#. It serve as information input form. The form encounters sort of random problem with the email field and state field. I have validator attached with these 2 fields as the following:
=====
<form id="creditcardform" method="post" runat="server">
Email: <asp:textbox id="txtBillEmail" maxlength="50" width="200" runat="server" /> <asp:requiredfieldvalidator id="vp10" runat="server" initialvalue=""
controltovalidate="txtBillEmail" errormessage="Billing Email cannot be empty" /> <asp:regularexpressionvalidator id="vp11" runat="server" controltovalidate="txtBillEmail" errormessage="Billing Email must follow em***@host.domain"
validationexpression="^.+\@.+\..+$" display="Dynamic" />

State: <asp:dropdownlist id="lstBillState" runat="server" />
<asp:requiredfieldvalidator id="vp7" runat="server" initialvalue=""
controltovalidate="lstBillState"
errormessage="Billing State must select one" display="Dynamic" />

<asp:button id="btnSubmit" causesvalidation="True" text="Submit" runat="server" cssclass="button" /> </form>
=====

My understanding is that the <asp:requiredfieldvalidator> should guarantee the value of the field when the value of "causesvalidation" sets to "True" in the submit button. But what happened was that no error was generated when "btnSubmit" was clicked, but
the value of one of these 2 fields get lost in the codebehind file. I tried
to catch it on our development server, but I've never caught it. It only
occurs on our production server. This problem doesn't always occur. It only happens once a while randomly.

Would you please help me to figure out the cause of such value loss?

Thank you

hb

Nov 19 '05 #3

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

Similar topics

6
by: BK | last post by:
I'm having a really strange problem with and HtmlSelect server control (listbox) and a RequiredFieldValidator that I am trying to use to make sure that someone has items in the listbox. The way...
0
by: Nicolas | last post by:
How can I have only one RequiredFieldValidator to control two TextBox webcontrols so that only one message is displayed <asp:Label id="lbl_UserName" runat="server"></asp:Label><br> <asp:TextBox...
3
by: me | last post by:
Is there any particular reason why a requiredfieldvalidator cant validate a listbox? I have bound the two together but the validator always returns false on isvalid and so does the Page, no matter...
7
by: Ed West | last post by:
Hello, I have a simple form with some input boxes. After validation if one fails, then I would like to at the top of the page say something like "The following fields in red are required" and...
4
by: James | last post by:
Hello, I have a RequiredFieldValidator for several textbox controls on a form. Here's an example with the RequiredFieldValidator. EnableClientScript, Enabled, and Visible are set to true for...
4
by: Joe | last post by:
Hello, I have created a login page using dotnet. I am using requiredFieldValidator and noticed that the code works fine in IE but not in Netscape, Opera, Mozilla, Firefox, etc. For example...
5
by: Fernando Lopes | last post by:
Hi. I want to show an image in a requiredfield validator instead of "*". So, I 'm set the requiredfieldvalidator attributes like following: <asp:RequiredFieldValidator id=rfvFirstName...
2
by: Christina | last post by:
Hello !! I am creating a dynamic textbox and want to validate it using the requiredfieldvalidator. These are the steps which I tried: ==================================================== 1)...
3
by: Bogdan | last post by:
Hi, I have a OnClientClick script assigned to a button. From the script, I'd like to check if RequiredFieldValidator attached to a textbox on the page has failed. The Page_IsValid works fine...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
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: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
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:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.