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.Set TextBox value based on CheckBox checked unchecked using jQuery in ASP.Net MVC<p>Hi&nbsp;nauna,</p> <p>You can handle the TextBox value from Controller.</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">Model</span></strong></p> <pre class="brush: csharp">public class CustomerModel { public bool Sw { get; set; } public string AboutMe { get; set; } }</pre> <p><strong><span style="text-decoration: underline;">Controller</span></strong></p> <pre class="brush: csharp">public class HomeController : Controller { // GET: /Home/ public ActionResult Index() { CustomerModel model = new CustomerModel(); model.Sw = true; if (model.Sw) { model.AboutMe = &#34;select&#34;; } return View(model); } }</pre> <p><strong><span style="text-decoration: underline;">View</span></strong></p> <pre class="brush: html">&lt;%@ Page Language=&#34;C#&#34; Inherits=&#34;System.Web.Mvc.ViewPage&lt;_CheckBox_Based_TextBox_MVC.Models.CustomerModel&gt;&#34; %&gt; &lt;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&gt; &lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head runat=&#34;server&#34;&gt; &lt;title&gt;Index&lt;/title&gt; &lt;link rel=&#34;stylesheet&#34; href=&#34;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css&#34; /&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(function () { $(&#39;[id*=chkStatus]&#39;).on(&#39;click&#39;, function () { if ($(this).is(&#39;:checked&#39;)) { $(&#39;[id*=txtAboutMe]&#39;).val(&#34;select&#34;); } else { $(&#39;[id*=txtAboutMe]&#39;).val(&#34;&#34;); } }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class=&#34;form-group&#34;&gt; &lt;%:Html.LabelFor(model =&gt; model.Sw)%&gt; &lt;div class=&#34;col-md-10&#34;&gt; &lt;div class=&#34;checkbox&#34;&gt; &lt;%:Html.CheckBoxFor(model =&gt; model.Sw, new { id=&#34;chkStatus&#34;, @class = &#34;form-control&#34; } )%&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;br /&gt; &lt;div class=&#34;form-group&#34;&gt; &lt;%:Html.LabelFor(model =&gt; model.AboutMe)%&gt; &lt;div class=&#34;col-md-10&#34;&gt; &lt;%:Html.TextBoxFor(model =&gt; model.AboutMe, new { id = &#34;txtAboutMe&#34;, @class = &#34;form-control&#34; })%&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/C1ABAtK.gif" alt="" width="250" height="200" /></span></strong></p>https://www.aspforums.net:443/Threads/830191/Set-TextBox-value-based-on-CheckBox-checked-unchecked-using-jQuery-in-ASPNet-MVC/https://www.aspforums.net:443/Threads/830191/Set-TextBox-value-based-on-CheckBox-checked-unchecked-using-jQuery-in-ASPNet-MVC/Wed, 12 Jun 2019 05:11:08 GMT