ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Show hide TextBox based on RadioButtonList selection in ASP.Net<p>Hi <a class="username" rel="nauna">nauna</a>,</p> <p>Please refer below sample code.</p> <p>Also refer below link-</p> <h1 class="header"><a title="Get Selected Text and Value of ASP.Net RadioButtonList using jQuery'a" href="http://www.jqueryfaqs.com/Articles/Get-Selected-Text-and-Value-of-ASP.Net-RadioButtonList-using-jQuery.aspx">Get Selected Text and Value of ASP.Net RadioButtonList using jQuery</a></h1> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;script type=&#34;text/javascript&#34; src=&#34;http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; &nbsp;&nbsp;&nbsp; $(function () { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TextBoxShowHide(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(&#34;#RadioButtonList2 [type=radio]&#34;).change(function () { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TextBoxShowHide(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }); &nbsp;&nbsp;&nbsp; }); &nbsp;&nbsp;&nbsp; function TextBoxShowHide() { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var val = $(&#39;#RadioButtonList2 input[type=radio]:checked&#39;).val(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (val == &#39;1&#39; || $(&#39;#RadioButtonList2 input[type=radio]:checked&#39;).length == 0) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(&#39;#&lt;%= TextBox11.ClientID%&gt;&#39;).hide(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById(&#34;&lt;%=TextBox3.ClientID %&gt;&#34;).disabled = false; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById(&#34;&lt;%=TextBox3.ClientID %&gt;&#34;).value = &#34;&#34;; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(&#39;#&lt;%= TextBox11.ClientID%&gt;&#39;).show(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById(&#34;&lt;%=TextBox3.ClientID %&gt;&#34;).disabled = true; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById(&#34;&lt;%=TextBox3.ClientID %&gt;&#34;).value = &#34;0&#34;; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp; } &lt;/script&gt; &lt;div&gt; &nbsp;&nbsp;&nbsp; &lt;asp:TextBox ID=&#34;TextBox11&#34; runat=&#34;server&#34; placeholder=&#34;Textbox 11&#34;&gt;&lt;/asp:TextBox&gt; &nbsp;&nbsp;&nbsp; &lt;asp:TextBox ID=&#34;TextBox3&#34; runat=&#34;server&#34; placeholder=&#34;Textbox 3&#34;&gt;&lt;/asp:TextBox&gt; &nbsp;&nbsp;&nbsp; &lt;asp:RadioButtonList ID=&#34;RadioButtonList2&#34; runat=&#34;server&#34;&gt; &nbsp;&nbsp;&nbsp; &lt;/asp:RadioButtonList&gt; &lt;/div&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Data; using System.Configuration; using System.Data.SqlClient;</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { string constr = ConfigurationManager.ConnectionStrings[&#34;Constring&#34;].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { string query = &#34;SELECT FruitName, FruitId FROM Fruits&#34;; using (SqlCommand cmd = new SqlCommand(query)) { cmd.CommandType = CommandType.Text; cmd.Connection = con; con.Open(); RadioButtonList2.DataSource = cmd.ExecuteReader(); RadioButtonList2.DataTextField = &#34;FruitName&#34;; RadioButtonList2.DataValueField = &#34;FruitId&#34;; RadioButtonList2.DataBind(); con.Close(); } } } }</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><img src="https://imgur.com/TudDEJR.gif" alt="" width="250" height="272" /></p>https://www.aspforums.net:443/Threads/520350/Show-hide-TextBox-based-on-RadioButtonList-selection-in-ASPNet/https://www.aspforums.net:443/Threads/520350/Show-hide-TextBox-based-on-RadioButtonList-selection-in-ASPNet/Mon, 15 Oct 2018 04:21:51 GMT