Re-enable RadButton with property SingleClick=true without postback

2 posts, 0 answers
  1. shinra
    shinra avatar
    3 posts
    Member since:
    Feb 2015

    Posted 07 Apr 2015 Link to this post

    Upon clicking btnSearch, it disables it with telerik's SingleClick=true property. If validation fails it doesn't postback and I try to set the button back to being enabled but it doesn't get set. It still is disabled with the text saying "Searching...".What I am trying to do is if it fails the validation, I want the button to be enabled again. Right now if i click on it and validation fails, it gets stuck being disabled.

     

    <telerik:RadButton ID="btnSearch"  Text="Search" SingleClick="true" OnClick="btnSearch_Click" OnClientClicking="Validate" SingleClickText="Searching..." ></telerik:RadButton>

     

    function Validate(button, args) {
         if (error) {
    button.set_autoPostBack(true);               
    } else { //validation fails                           
    button.set_autoPostBack(false);                 
    button.set_enabled(true); // i have currently              
     }

  2. Misho
    Admin
    Misho avatar
    129 posts

    Posted 10 Apr 2015 Link to this post

    Hello,

    I've tried to replicate the scenario with RadButton getting disabled when validation fails but not avail.
    Here is a video showing my test:
    http://screencast.com/t/F47ZLlCh
    I'm attaching a small code snippet showing the markup I've used for your convenience:
    <telerik:RadTextBox ID="RadTextBox1" runat="server">
           </telerik:RadTextBox>
           <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="Server" ControlToValidate="RadTextBox1" EnableClientScript="True" ErrorMessage="!" Font-Bold="true" Font-Size="Large" ForeColor="Maroon"></asp:RequiredFieldValidator>
           <telerik:RadButton ID="btnSearch" runat="server" Text="Search" SingleClick="true" OnClick="btnSearch_Click"
               OnClientClicking="Validate" SingleClickText="Searching...">
           </telerik:RadButton>
           <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
           <script runat="server">
               protected void btnSearch_Click(object sender, EventArgs e)
               {
                   System.Threading.Thread.Sleep(2000);
                   Label1.Text = "RadButton1 Click Handler";
     
               }
               protected void Page_load(object sender, EventArgs e)
               {
                   if (IsPostBack)
                       Label1.Text += " RadButton1 Postback";
               }
           </script>
           <script type="text/javascript">
               function Validate(button, args) {
                   //if (error) {
                   //    button.set_autoPostBack(true);
                   //} else { //validation fails                          
                   //    button.set_autoPostBack(false);
                   //    button.set_enabled(true); // i have currently             
                   //}
               }
           </script>

    If you are still experiencing issues with the validation, please modify it in accordance with your custom set up and send it back so that we will be able to investigate it in more details on our side.

    Best Regards,
    Misho
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top