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

Validation problem with radbutton

1 Answer 314 Views
Button
This is a migrated thread and some comments may be shown as answers.
SR
Top achievements
Rank 1
SR asked on 24 Jan 2014, 01:57 PM

I am having a RadButton control in  form and datepiccker Date is mandatory .
not selected the date the alert shown plz select date and one more alert come again are you sure?
when i was click on ok button saved successfully with out date but  validation failed, Removevalidationgroup working fine
how to do this on client side Is page is Valid ?

Here is the code give me any valuable suggestions 
aspx
 <telerik:RadButton ID="btnSave" runat="server" Text="Save"  OnClick="btnSave_Click" OnClientClicking="RadConfirm" ValidationGroup="dbgrpMandate"></telerik:RadButton>

js
 //RadConfirm
        function RadConfirm(sender, args) {
            var callBackFunction = Function.createDelegate(sender, function (shouldSubmit) {
                if (shouldSubmit) {
                    this.click();
                }
            });

            var text = "Are you sure ?";
            radconfirm(text, callBackFunction, 250, 120, null, "radConfirm");
            args.set_cancel(true);
        }

1 Answer, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 29 Jan 2014, 09:04 AM
Hi Suman,

Could you please elaborate more into what is the actual and the expected behavior of the RadButton? Note that:
  • OnClientClicking event is raised before the client-side validation and can be canceled.
  • OnClientClicked event is raised after the client-side validation and cannot be canceled.
If you want to popup the radconfirm dialog only if the page is valid than you can put such a flag there. For example:
JavaScript:
<script>
    function RadConfirm(sender, args) {
 
        var callBackFunction = Function.createDelegate(sender, function (shouldSubmit) {
            if (shouldSubmit) {
                this.click();
            }
        });
 
        var text = "Are you sure ?";
        if (Page_IsValid) {
            radconfirm(text, callBackFunction, 250, 120, null, "radConfirm");
            args.set_cancel(true);
        }
    }
</script>
ASPX:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
    <asp:TextBox ID="Textbox1" runat="server" ValidationGroup="dbgrpMandate" />
    <asp:Label ID="Label1" Text="" runat="server" />
    <telerik:RadButton ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" OnClientClicking="RadConfirm" ValidationGroup="dbgrpMandate">
    </telerik:RadButton>
    <asp:RequiredFieldValidator ID="Requiredfieldvalidator1" ErrorMessage="errormessage" ControlToValidate="Textbox1" runat="server" ValidationGroup="dbgrpMandate" />
C#:
protected void Page_Load(object sender, EventArgs e)
{
 
}
protected void btnSave_Click(object sender, EventArgs e)
{
    Label1.Text = "server-side click triggered";
}

I have also attached the full VS example to this post.

If the above step, however, is not  helpful could you please paste the problematic code and then tell us what is the expected behavior from the RadButton?

Regards,
Danail Vasilev
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Button
Asked by
SR
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or