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

Validation only when the user hits button

Hi,

I have very simple code:

<asp:TextBox ID="TextBox1" runat="server"/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"

ControlToValidate="TextBox1"
ValidationGroup="1"> <asp:Button ID="Button1" runat="server"
Text="Button 1" ValidationGroup="1"
CausesValidation="true" />

I would like RequiredFieldValidator1 to fire only when I hit Button1
button. But it also fires when
text box TextBox1 looses focus. For example when I finish typing and
hit TAB key. Is there any way in order to prevent
RequiredFieldValidator1 from firing too early?

thanks in advance for any info

Pawel Pabich

May 31 '06 #1
2 1486
You can try setting the CausesValidation property of the textbox to false.

ASP.NET 2.0 has far more granular control over validation. You can say "I
want all these validators to be fired by this button only, and this 2nd
group to be fired by this other button here"...

Karl

--
http://www.openmymind.net/

"Pawel Pabich" <pa**********@gmail.com> wrote in message
news:11**********************@h76g2000cwa.googlegr oups.com...
Hi,

I have very simple code:

<asp:TextBox ID="TextBox1" runat="server"/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"

ControlToValidate="TextBox1"
ValidationGroup="1"> <asp:Button ID="Button1" runat="server"
Text="Button 1" ValidationGroup="1"
CausesValidation="true" />

I would like RequiredFieldValidator1 to fire only when I hit Button1
button. But it also fires when
text box TextBox1 looses focus. For example when I finish typing and
hit TAB key. Is there any way in order to prevent
RequiredFieldValidator1 from firing too early?

thanks in advance for any info

Pawel Pabich

May 31 '06 #2
Hi Karl,

thanks for your answer but it does not help. It makes sense to set
CausesValidation to fale when the text box casues post back and my
text box doesn't. I thought that if a validator is member of any
validation
group then it needs to wait for button or any other control that causes
validation
but it seems I'm wrong.

Pawel Pabich

Karl Seguin [MVP] wrote:
You can try setting the CausesValidation property of the textbox to false.

ASP.NET 2.0 has far more granular control over validation. You can say "I
want all these validators to be fired by this button only, and this 2nd
group to be fired by this other button here"...

Karl

--
http://www.openmymind.net/

"Pawel Pabich" <pa**********@gmail.com> wrote in message
news:11**********************@h76g2000cwa.googlegr oups.com...
Hi,

I have very simple code:

<asp:TextBox ID="TextBox1" runat="server"/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"

ControlToValidate="TextBox1"
ValidationGroup="1"> <asp:Button ID="Button1" runat="server"
Text="Button 1" ValidationGroup="1"
CausesValidation="true" />

I would like RequiredFieldValidator1 to fire only when I hit Button1
button. But it also fires when
text box TextBox1 looses focus. For example when I finish typing and
hit TAB key. Is there any way in order to prevent
RequiredFieldValidator1 from firing too early?

thanks in advance for any info

Pawel Pabich


May 31 '06 #3

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

Similar topics

8
by: moondaddy | last post by:
I have a form for entering a user's address and all fields have a required validating control associated with them and the error msg for each field displays right next to it. The normal behavior...
9
by: AFN | last post by:
I was just dropped into someone else's code (isn't that always so fun?). I can't figure out why a custom validation control's server event function is executing. There is nothing (that I see)...
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......
5
by: Micky | last post by:
VB v7.1.3088 NET v1.1.4322 SP1 My mate has a strange problem regarding the ESC key and validation. When he hits the Cancel button on his form, the form does not validate. This is correct...
9
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be...
1
by: JohnR | last post by:
I normally validate the data in a control in that controls validating event. I also normally have a Cancel button on each form which does a RejectChanges to reset any unsaved data on the form. ...
1
by: John Chan | last post by:
Hi, Im doing a maintenance application in ajax and coldfusion at work on IE6 exclusively. I have a save button on each form and i have to do various validations server side and on client side...
1
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post by:
I'm having trouble working with a Summary Validation control. I need to click my submit button twice for the Summary to display when validation errors occur on the page. Background: My page...
0
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post by:
I'm having trouble working with a Summary Validation control. I need to click my submit button twice for the Summary to display when validation errors occur on the page. Background: My page...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.