Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Validation control

Reply
Thread Tools

Validation control

 
 
simon
Guest
Posts: n/a
 
      05-12-2004
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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?TGFrc2htaSBNdXJ0aHk=?=
Guest
Posts: n/a
 
      05-12-2004
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
 
Reply With Quote
 
 
 
 
BlackMagic
Guest
Posts: n/a
 
      05-12-2004
You could set the CausesValidation property of your Cancel button to False.
This has worked for me.

HTH

"simon" <(E-Mail Removed)> wrote in message
news:%230oT9j$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom validation on a control in a user control.(asp.net 2.0) Jens Jensen ASP .Net 0 07-07-2006 09:46 AM
PasswordRecovery control trips Login control's validation The Colonel ASP .Net 1 07-06-2006 09:18 PM
Using Summary Validation control with server Custom validation =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= ASP .Net 2 10-15-2004 06:15 PM
Displaying a Validation Error in a Validation Summary Control Lucas Tam ASP .Net 2 02-26-2004 07:49 PM
Re: only custom validation control does server side validation? Colin Mackay ASP .Net 0 06-25-2003 07:54 AM



Advertisments