Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir,
I want to use JQuery in asp.net. I have four textbox and two checkbox. When click on checkbox then only any of two textbox box is visible and other two is not visible.
Posted
Comments
Al Moje 22-Dec-11 2:34am    
Could you post your code?...
RaviRanjanKr 22-Dec-11 17:10pm    
Its not easy to say whats going wrong without getting your effort. so please mention your Codes :)

Use Hide() and Show() of JQuery
jquery_effects
JQuery with asp.net
 
Share this answer
 
Try this,

HTML
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>


ASP.NET
<asp:checkbox id="chkTest" runat="server" xmlns:asp="#unknown" /> Toggle Enable/Disable
   <br />
  text1 <asp:textbox id="TextBox1" runat="server"></asp:textbox> <br /><br />
  text2 <asp:textbox id="TextBox2" runat="server"></asp:textbox> <br /><br />
  text3 <asp:textbox id="TextBox3" runat="server"></asp:textbox> <br /><br />
  text4 <asp:textbox id="TextBox4" runat="server"></asp:textbox>


HTML
<script language="javascript" type="text/javascript">
      
             $(function () { 
 
                    $('#<%= chkTest.ClientID  %>').click(function (e) { 
             
                        var textBox1 = $('#<%= TextBox1.ClientID %>');
                        var textBox2 = $('#<%= TextBox2.ClientID %>'); 
             
                        if (this.checked) { 
                            textBox1.attr('disabled', true);
                            textBox2.attr('disabled', true); 
                        } 
                        else { 
                            textBox1.removeAttr('disabled');
                             textBox2.removeAttr('disabled'); 
                        } 
                        }); 
                 
                    }); 
     
      </script>
 
Share this answer
 
v4
Comments
m_Shadman 9-May-12 12:37pm    
Thank you for solution.
I have a another question about select controls in a DetailsView with a selector command, like this: $("#btnSend").click();
How access to this control in DetailsView?

Tnx.
[no name] 22-May-12 5:45am    
how do we set Ideal time out through JQuery in web page?
Try
http://www.dotnetcurry.com/ShowArticle.aspx?ID=231[^]
http://jquery-with-asp.net/[^]

and please come back with your codes to find out whats going wrong. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900