Disable button with RadConfirm

0 Answers 123 Views
General Discussions
Vitaly
Top achievements
Rank 1
Iron
Iron
Vitaly asked on 21 Mar 2023, 01:13 PM

Good morning,

I have link button in my aspx file:

<asp:LinkButton ID="LinkButton1" Font-Size="X-Small" TabIndex="-1"
                                                                            Height="25px" Width="90px" Visible="false" BorderColor="WhiteSmoke" BackColor="#5A8EC1" BorderStyle="Solid" ForeColor="White" OnClientClick="approveConfirm();return false;"  runat="server" Font-Names="Verdana">APPROVE</asp:LinkButton>

Below is approveConfirm() function:

                  

 

    <script type="text/javascript">


        function approveConfirm() {

            if (radconfirm("Are you sure you want to Approve and ready to proceed?", callbackFn2, 400, 200, null)) {
                return false;
            }
            else {
                return true;
            }

        }
        function callbackFn2(arg) {

            var ajaxManager = $find("<%=RadAjaxManager1.ClientID%>");
            if (arg) {
                ajaxManager.ajaxRequest('okApprove');
            }
            else {
                ajaxManager.ajaxRequest('notApprove');
            }

 

For some reason when Linkbutton is disabled, and I still was able to click on this button and confirm popup message appeared. I need only to appeared confirm popup message when button is enabled.

Thanks so much for your help.

Rumen
Telerik team
commented on 24 Mar 2023, 07:50 AM

Hi Vitaly,

The behavior is not Telerik-related and will happen if you replace the radConfirm function with a standard alert.

You can find out how to achieve your goal in these resources:

Here is an example:

ASPX

        <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        </telerik:RadWindowManager>
        <asp:LinkButton ID="LinkButton1" Font-Size="X-Small" TabIndex="-1" Enabled="false"
            Height="25px" Width="90px" Visible="true" BorderColor="WhiteSmoke"
            BackColor="#5A8EC1" BorderStyle="Solid" ForeColor="White"
            OnClientClick="approveConfirm();return false;" runat="server" Font-Names="Verdana">APPROVE</asp:LinkButton>

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager>



        <script type="text/javascript">
            function approveConfirm() {
                alert("click is fired even when the button is disabled!");
                if (radconfirm("Are you sure you want to Approve and ready to proceed?", callbackFn2, 400, 200, null)) {
                    return false;
                }
                else {
                    return true;
                }

            }
            function callbackFn2(arg) {

                var ajaxManager = $find("<%=RadAjaxManager1.ClientID%>");
                if (arg) {
                    ajaxManager.ajaxRequest('okApprove');
                }
                else {
                    ajaxManager.ajaxRequest('notApprove');
                }
            }
        </script>

ASPX.CS

        protected void Page_Load(object sender, EventArgs e)
        {
            DisableLinkButton(LinkButton1);
        }

        public static void DisableLinkButton(LinkButton linkButton)
        {
            linkButton.Attributes.Remove("href");
            linkButton.Attributes.CssStyle[HtmlTextWriterStyle.Color] = "gray";
            linkButton.Attributes.CssStyle[HtmlTextWriterStyle.Cursor] = "default";
            if (linkButton.Enabled != false)
            {
                linkButton.Enabled = false;
            }

            if (linkButton.OnClientClick != null)
            {
                linkButton.OnClientClick = null;
            }
        }

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
Vitaly
Top achievements
Rank 1
Iron
Iron
Share this question
or