PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 3.00 average.

CustomValidator ClientValidationFunction OnServerValidate Confusion

 
 
labogart@hotmail.com
Guest
Posts: n/a
 
      18th Nov 2009
I have a form that has a textbox and a CustomValidator on it where I
need to perform some validation on both the client and also on the
server. I have a button on the form that saves the data. If I change
nothing in the field and hit the Save button, then Client side
validation occurs, the page does a postback and then the server side
validation occurs. If I change the data in the textfield, however,
and hit the save button then only the client side validation occurs,
the page does NOT postback and the server side validation does not
occur. At this point, I have the logic set so that it isn't really
even doing any validation (just setting IsValid = true) and it is
still doing this. Anyone have any idea what I am doing wrong?

<asp:TextBox ID="txtEmailAddress" MaxLength="255" runat="server"
Width="400px" CssClass="controlText" />

I have a customer validator set up as follows:

<asp:CustomValidator ID="CustomValidator1"
ClientValidationFunction="ClientSideValidate"
OnServerValidate="ServerValidation" EnableClientScript="true"
runat="server" ErrorMessage="Some Error Message"
ControlToValidate="txtEmailAddress" />

Client side Valdiation is as follows:
function ClientSideValidate(source, args)
{
//perform some validation
args.IsValid = true;

}

Server side Validation logic is as follows:
Sub ServerValidation(ByVal source As Object, ByVal args As
ServerValidateEventArgs)

'Perform some validation logic
args.IsValid = True

End Sub

Form has a button on it to save:

<asp:LinkButton ID="lnkSave" runat="server" ><img src="images/
save.jpg" class="imgButton" alt="Save" /></asp:LinkButton>


AutoEventWireup="false"
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
ASP.NET 2.0 clientvalidationfunction Firing When it Shouldn't mwieder@gmail.com Microsoft ASP .NET 10 5th Apr 2006 12:05 AM
ASP.NET 2.0 clientvalidationfunction Firing When it Shouldn't mwieder@gmail.com Microsoft ASP .NET 0 3rd Apr 2006 09:07 PM
CustomValidator.ClientValidationFunction not virtual Oleg Ogurok Microsoft ASP .NET 1 5th Jul 2005 05:45 PM
OnServerValidate Mike P Microsoft ASP .NET 3 23rd Oct 2003 03:12 PM
Question about OnServerValidate jm Microsoft ASP .NET 3 16th Oct 2003 10:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:10 AM.