Validation problem with radbutton

2 posts, 0 answers
  1. SR
    SR avatar
    33 posts
    Member since:
    Dec 2013

    Posted 24 Jan 2014 Link to this post

    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);
            }
  2. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1492 posts

    Posted 29 Jan 2014 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top