Let me explain what I'm doing. I have a form with some fields that are mark as required. I've been using a
requiredFieldValidatorand when the user click on the button which contian the
ValidationGroupproperty to be executed it works OK. It displayed in a
window alertthose fields that are missing.
Now, what's the problem? Well, the thing is that there are some validation that need to be perform in the client side. So, I added the
OnClientClickproperty to the same button which contain the ValidationGroup. And here is where I have been having some details. The JS function that is executed on the OnClientClick return a boolean value. This is with the porpouse
to execute the server side method of that button when the validations are OK. And again it works OK. Buut, the problem is that the alert window for the ValidationGroup is not dispalyed.
So, my question would be. Could I use both the ValidationGroup and the OnclientClick properties to coexits for the same control (a button)?
Thanks for your help. I tried the approch your posted and it works fine when you only have one ValidationGroup on your page. However, when the page have more than one ValidationGroup it fires all them.
I fixed my problem just like this: OnClientClick = "CustomValidate();"
Notice, that I'm not using the return. I mean: OnclientClick = "return CustomValidate();"
I don't undesrtand very well why this fixed it because in some other codes I have the return. Well, but it works ;-)
Hope this helps
Marked as answer by Lesthad_mk on Feb 26, 2013 11:05 PM
Lesthad_mk
Member
98 Points
161 Posts
ValidationGroup is not working properly when using onClientClick
Feb 26, 2013 04:34 AM|LINK
Hi
Let me explain what I'm doing. I have a form with some fields that are mark as required. I've been using a requiredFieldValidator and when the user click on the button which contian the ValidationGroup property to be executed it works OK. It displayed in a window alert those fields that are missing.
Now, what's the problem? Well, the thing is that there are some validation that need to be perform in the client side. So, I added the OnClientClick property to the same button which contain the ValidationGroup. And here is where I have been having some details. The JS function that is executed on the OnClientClick return a boolean value. This is with the porpouse to execute the server side method of that button when the validations are OK. And again it works OK. Buut, the problem is that the alert window for the ValidationGroup is not dispalyed.
So, my question would be. Could I use both the ValidationGroup and the OnclientClick properties to coexits for the same control (a button)?
I hope you can help me
Regrdas!
kedarrkulkar...
All-Star
35559 Points
5698 Posts
Re: ValidationGroup is not working properly when using onClientClick
Feb 26, 2013 05:12 AM|LINK
try this
change OnClientClick attribute as below.... assuming the name of function which is called for OnClientClick is "CustomValidate()"
<asp:Button id="btnSave" runat="server" ValidationGrouup="something" OnClientClick="if(Page_ClientValidate()) CustomValidate();" .../>
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
Lesthad_mk
Member
98 Points
161 Posts
Re: ValidationGroup is not working properly when using onClientClick
Feb 26, 2013 11:05 PM|LINK
Hi Kedarr
Thanks for your help. I tried the approch your posted and it works fine when you only have one ValidationGroup on your page. However, when the page have more than one ValidationGroup it fires all them.
I fixed my problem just like this: OnClientClick = "CustomValidate();"
Notice, that I'm not using the return. I mean: OnclientClick = "return CustomValidate();"
I don't undesrtand very well why this fixed it because in some other codes I have the return. Well, but it works ;-)
Hope this helps