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

Re-enable RadButton with property SingleClick=true without postback

1 Answer 242 Views
Button
This is a migrated thread and some comments may be shown as answers.
shinra
Top achievements
Rank 1
shinra asked on 07 Apr 2015, 04:12 PM

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              
 }

1 Answer, 1 is accepted

Sort by
0
Misho
Telerik team
answered on 10 Apr 2015, 06:35 AM
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.

 
Tags
Button
Asked by
shinra
Top achievements
Rank 1
Answers by
Misho
Telerik team
Share this question
or