I need to find a way to either
1. run and check all Validation controls (in my case one
case I'll use <asp:Button>. So if all validation passes, run custom
perform remaining client side function. So in this case I'll use
So far, challenge in case 1 is how to capture validation failure and
limit and stop further client side code execution. I had this code.
Page.ClientScript.GetPostBackEventReference(Button _Search, "") +
where Search() is my client side function, which gets executed with
failed client side validation.
In case 2, I would like to do something like... (I'm doing this with
window.top._somevalue = 'xyz';
if (whateverclientvalidationfuctioniscalled()) // client side
validation function name generated by ASP.NET
<input type="button" onclick="Search();">
Any help appreciated.
I think you are trying to do what I do. Here is what I do:
In the code-behind:
// Add Submit Confirmation
btnSubmit.Attributes.Add("onClick", "return ConfirmSubmit();");
Then in your aspx page within script tags:
this.IsValid = true;
this.errorMsg = "";
var IsValid = true;
var display = "";
var err = new errorArgs();
VerifyVacationDays(err); // Create your validation code in here.
// I have multiple validation routines that I call, but I put it
down to 1 for ease of reading
return confirm('Are you sure you want to Submit?');
The key is the "return" in the buttons OnClick event. If it sees
false it will not post back. If it sees true it will.
Thanks for quick response.
So looks like you are calling your own validation functions. I would
like to utilize already generated server-side validation. I just
found my own answer just after posting.
With case 2, where...
if (Page_ClientValidate('SearchValidation')) // that was the function
name I was looking for. SearchValidation is the ValidationGroup name.
and used in server side....
<asp:Button ID="Button_Search" runat="server" Text="Search"
ValidationGroup="SearchValidation" OnClientClick="Search();" />
I'm not sure <asp:Button> is completely necessary or not here but I'll
move on. Thanks again.
|All times are GMT. The time now is 05:27 AM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.