473,398 Members | 2,427 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,398 software developers and data experts.

Validation control

I have textBox and field validator on my panel:

<asp:TextBox id="txtID" Runat="server" Text="" Columns="5"></asp:TextBox>
<asp:RequiredFieldValidator id="Requiredfieldvalidator2" runat="server"
ErrorMessage="Enter in the typeID."
ControlToValidate="txtID"></asp:RequiredFieldValidator>

Then I have INSERT and CANCEL buttons.

If the user clicks INSERT button then the txtID should be client and server
validate,
but if user clicks CANCEL button, the validation should be omitted,
panel.visible=false and I show him something else.

Now If I clicks the Cancel button, the validation control doesn't allow me
to post the page.

Does anybody know the solution?

Thank you,
Simon
Nov 18 '05 #1
2 1085
Hi Simon,

You can hide the error message of the RequiredFieldValidation control on the click of CANCEL button by using javascript.
you need to create a function and insert a dummy value for the validation control.Then you need to call this function in the onclick event of the CANCEL Button.

For example:

<head><script lang="Javascript">

function setDummy()

{

var Objtxt = document.getElementById("txtName")

if (Objtxt!=null) {

Objtxt.value ="dummy"

}

}

</script></head><body>
...
<asp:Button id="Button2" style="Z-INDEX: 104; LEFT:192px; POSITION: absolute; TOP: 112px" runat="server"
Width="72px" Text="Cancel" onclick="javascript:setDummy();"></asp:Button>

Now,you will not see the error message on the click of CANCEL button.

Hope that helps
Regards
Lakshmi
Nov 18 '05 #2
You could set the CausesValidation property of your Cancel button to False.
This has worked for me.

HTH

"simon" <si*********@stud-moderna.si> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I have textBox and field validator on my panel:

<asp:TextBox id="txtID" Runat="server" Text="" Columns="5"></asp:TextBox>
<asp:RequiredFieldValidator id="Requiredfieldvalidator2" runat="server"
ErrorMessage="Enter in the typeID."
ControlToValidate="txtID"></asp:RequiredFieldValidator>

Then I have INSERT and CANCEL buttons.

If the user clicks INSERT button then the txtID should be client and server validate,
but if user clicks CANCEL button, the validation should be omitted,
panel.visible=false and I show him something else.

Now If I clicks the Cancel button, the validation control doesn't allow me
to post the page.

Does anybody know the solution?

Thank you,
Simon

Nov 18 '05 #3

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

Similar topics

4
by: Tim Meagher | last post by:
I am trying to use both validation controls and to add submit button attributes, but when I add the button attributes, the javascript fpr the validation controls is no longer created for the page. ...
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...
7
by: A.M | last post by:
Hi, I have a validation control in my page that upon any invalid data, it disables all buttons in the page. basicly i don't have any postback in the page if the validator finds any error. How...
14
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
2
by: Martyn Fewtrell | last post by:
Dear All I have a Windows 2003 Server with IIS6 where the validation controls on ASP.Net pages no longer work. I believe it to be specific to the server as if I create an ASP.Net page on the...
2
by: Barbara Alderton | last post by:
I setup some standard Required Field Validation controls and one Custom validation control on an ASP.NET page (within a user control) to validate text entry. I also setup a Summary Control to post...
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......
2
by: Tim Frawley | last post by:
Source code attached indicates my problem with validation and a button bar save button. Fill the Textbox with some text then tab off the control. The message box will display the text in the...
1
by: Buddy Ackerman | last post by:
I don't know what the problem is. I have a form with several controls that need to be validated, I put a validation group in every form control, every validatoino control, the submit button and...
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: 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: 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
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...
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.