c# - How to disable button and then enable it after textbox.textchanged event? -


i have user control acts form updating student records. user control used in page called students update. after update sucessfull, want disable update button. after that, if user changes text, update button should enabled back. trying not working. have textboxes autopost property true. able disable, not able enable again if user starts entering new text in text box. using textbox.textchanged event achieve this.

a jquery approach :

<body>     <form id="form1" runat="server">     <div>         <asp:textbox id="textbox1" runat="server"></asp:textbox>         <asp:button id="button1" runat="server" text="button" enabled="false" />     </div>     </form>     <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>     <script type="text/javascript">         $("#<%= textbox1.clientid %>").keyup(function () {                 $("#<%= button1.clientid %>").attr("disabled", $(this).val() == "");         });     </script>   </body> 

or can server-side :

<asp:textbox id="textbox1" runat="server" autopostback="true" ontextchanged="textbox1_textchanged"></asp:textbox> <asp:button id="button1" runat="server" enabled="false" text="button" />  protected void textbox1_textchanged(object sender, eventargs e) {     button1.enabled = !string.isnullorempty(textbox1.text); } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -