This is a migrated thread and some comments may be shown as answers.

CausesValidation issues? RadButton and RadComboBox

2 Answers 82 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rob Ainscough
Top achievements
Rank 1
Rob Ainscough asked on 05 Mar 2019, 11:27 PM

I have a RadComboBox that I don't want to trigger any validation checking (I have several controls using asp:RequireFieldValidator) ... so I set the CausesValidation='false'

<telerik:RadComboBox ID="rcb_Insurances" runat="server" Width="100%" AutoPostBack="true" CausesValidation="false"/>

 

and on the same page I have a RadButton that I DO want to trigger validation checking so ...

<telerik:RadButton ID="rbn_MakePayment" runat="server" Text="Pay Now" Font-Size="X-Large" OnClick="MakePayment" CausesValidation="true"></telerik:RadButton>

 

So validation is NOT performed when I check an item in my RadComboBox.  However, when I click my RadButton validation is not triggered? 

If I remove the CausesValidation=false on the RadComboBox then my RadButton will trigger validation.

Ideas?

Cheers, Rob.

 

 

2 Answers, 1 is accepted

Sort by
0
Rob Ainscough
Top achievements
Rank 1
answered on 06 Mar 2019, 12:10 AM

After some more research I came across this Telerik article which has left me wanting a career change:

... https://docs.telerik.com/devtools/aspnet-ajax/controls/button/how-to/radbutton-validation-and-client-side-event-handlers

So the validators I've setup on the controls will NOT be validated until AFTER I execute the code in my event handler method (OnClick="MakePayment").  At what point would this EVER EVER EVER be desirable????

It also begs the question of what is the point to "CausesValidation" property if the control validation actually happens AFTER code execution?

This is probably some bizarre limitation around HTTP and stateless, but I can't begin to understand what or why?  Sure the CausesValidation=true should operate the control validators first and if all valid, then continue to my MakePayment method.

Is there any way around this bizarre process?

Cheers, Rob.

 

 

0
Rob Ainscough
Top achievements
Rank 1
answered on 06 Mar 2019, 10:10 PM

I researched and tested some more and found a solution ... the Page.IsValid will be set based on the Validators evaluation.  So in my OnClick method I just need to check Page.IsValid and exit or proceed based on True/False.

Cheers, Rob.

Tags
General Discussions
Asked by
Rob Ainscough
Top achievements
Rank 1
Answers by
Rob Ainscough
Top achievements
Rank 1
Share this question
or