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

RequiredFieldValidator in action immediately in fresh form

Hi !

I'm using Visual Studio .NET to program a Web application coding in C#.

In my form I use an HtmlSelect control that calls a JavaScript function when
the selected item changes.
This JavaScript function calls the submit() method of the form.

For this HtmlSelect control I have also programmed the ServerChange event,
which is able to dynamically set up the form.

Depending on the item selected, this set-up adds an input field and an
associated RequiredFieldValidator.
I want the input field to be empty initially, but, unfortuantely,
the RequiredFieldValidator seems to act immediately when the fresh page
comes from the server.

I didn't have this problem as long as I was using a
System.Web.UI.WebControls.DropDownList instead of the HtmlSelect control,
but I would like to keep the Html control, in order to call my own
JavaScript when the selected item changes.

Is there a way to suppress the above mentioned initial validation when the
page is loaded afresh.

Your kind advice would be appreciated.

Peter


Nov 18 '05 #1
2 5313
When the page is set to IsPostBack=true, each validator shows its error
message when the IsValid property is false. Try this: after the page is
validated (you are probably calling Page.Validate()), set the
RequiredFieldValidator.IsValid property to true.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"peshrad" <pe*****@BieberGruppe.de> wrote in message
news:uy**************@tk2msftngp13.phx.gbl...
Hi !

I'm using Visual Studio .NET to program a Web application coding in C#.

In my form I use an HtmlSelect control that calls a JavaScript function when the selected item changes.
This JavaScript function calls the submit() method of the form.

For this HtmlSelect control I have also programmed the ServerChange event,
which is able to dynamically set up the form.

Depending on the item selected, this set-up adds an input field and an
associated RequiredFieldValidator.
I want the input field to be empty initially, but, unfortuantely,
the RequiredFieldValidator seems to act immediately when the fresh page
comes from the server.

I didn't have this problem as long as I was using a
System.Web.UI.WebControls.DropDownList instead of the HtmlSelect control,
but I would like to keep the Html control, in order to call my own
JavaScript when the selected item changes.

Is there a way to suppress the above mentioned initial validation when the
page is loaded afresh.

Your kind advice would be appreciated.

Peter

Nov 18 '05 #2
When the page is set to IsPostBack=true, each validator shows its error
message when the IsValid property is false. Try this: after the page is
validated (you are probably calling Page.Validate()), set the
RequiredFieldValidator.IsValid property to true.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"peshrad" <pe*****@BieberGruppe.de> wrote in message
news:uy**************@tk2msftngp13.phx.gbl...
Hi !

I'm using Visual Studio .NET to program a Web application coding in C#.

In my form I use an HtmlSelect control that calls a JavaScript function when the selected item changes.
This JavaScript function calls the submit() method of the form.

For this HtmlSelect control I have also programmed the ServerChange event,
which is able to dynamically set up the form.

Depending on the item selected, this set-up adds an input field and an
associated RequiredFieldValidator.
I want the input field to be empty initially, but, unfortuantely,
the RequiredFieldValidator seems to act immediately when the fresh page
comes from the server.

I didn't have this problem as long as I was using a
System.Web.UI.WebControls.DropDownList instead of the HtmlSelect control,
but I would like to keep the Html control, in order to call my own
JavaScript when the selected item changes.

Is there a way to suppress the above mentioned initial validation when the
page is loaded afresh.

Your kind advice would be appreciated.

Peter

Nov 18 '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...
5
by: bissatch | last post by:
Hi, I have been trying to come up with an idea to reduce double submissions where a user clicks refresh and, for example, another row is INSERT into a table. Originally, I would have a form...
1
by: ad | last post by:
I want to combine a TextBox and a RequiredFieldValidator into to a web custom control (name RequireTextBox ), But when I use RequireTextBox in web form, the RequiredFieldValidator has no action....
1
by: peshrad | last post by:
Hi ! I'm using Visual Studio .NET to program a Web application coding in C#. In my form I use an HtmlSelect control that calls a JavaScript function when the selected item changes. This...
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...
2
by: Hongbo | last post by:
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...
1
by: Arpan | last post by:
Suppose I have the following RequiredFieldValidator control which validates a TextBox: <form id="form1" runat="server"> <asp:TextBox id="txtVal" runat="server"/> <asp:RequiredFieldValidator...
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)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.