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.Clear ASP.Net TextBox value and CheckBoxList selection on jQuery Sweet alert Ok Button Click using C# and VB.Net<p>Hi<a class="username" rel="democloud">democloud,</a></p> <p>You need to use&nbsp;.then and do the TextBox and CheckBox clear using jQuery. Create a JavaScript function and call it in code behind.&nbsp;</p> <p>Refer below example.</p> <p><strong><span style="text-decoration: underline;">HTML</span></strong></p> <pre class="brush: html">&lt;asp:TextBox ID=&#34;TextBox4&#34; runat=&#34;server&#34; Text=&#34;Test 1&#34;&gt;&lt;/asp:TextBox&gt;&lt;br /&gt; &lt;asp:TextBox ID=&#34;TextBox5&#34; runat=&#34;server&#34; Text=&#34;Test 2&#34;&gt;&lt;/asp:TextBox&gt;&lt;br /&gt; &lt;asp:TextBox ID=&#34;TextBox6&#34; runat=&#34;server&#34; Text=&#34;Test 3&#34;&gt;&lt;/asp:TextBox&gt;&lt;br /&gt; &lt;asp:CheckBoxList ID=&#34;CheckBoxList1&#34; name=&#34;Test&#34; runat=&#34;server&#34; OnSelectedIndexChanged=&#34;CheckBox1_CheckedChanged&#34; AutoPostBack=&#34;true&#34;&gt; &lt;asp:ListItem Value=&#34;Monday&#34;&gt;Monday&lt;/asp:ListItem&gt; &lt;/asp:CheckBoxList&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.5/bluebird.min.js&#34;&gt;&lt;/script&gt; &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; src=&#34;http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js&#34;&gt;&lt;/script&gt; &lt;link rel=&#34;stylesheet&#34; href=&#34;http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css&#34; /&gt; &lt;script type=&#34;text/javascript&#34; src=&#39;https://cdn.jsdelivr.net/sweetalert2/6.3.8/sweetalert2.min.js&#39;&gt; &lt;/script&gt; &lt;link rel=&#34;stylesheet&#34; media=&#34;screen&#34; href=&#39;https://cdn.jsdelivr.net/sweetalert2/6.3.8/sweetalert2.min.css&#39; /&gt; &lt;link rel=&#34;stylesheet&#34; media=&#34;screen&#34; href=&#39;https://cdn.jsdelivr.net/sweetalert2/6.3.8/sweetalert2.css&#39; /&gt; &lt;script type=&#34;text/javascript&#34;&gt; function AlertClear(selected) { swal({ text: &#34;Not available&#34; }).then(function () { document.getElementById(&#39;&lt;%=TextBox4.ClientID%&gt;&#39;).value = &#34;&#34;; document.getElementById(&#39;&lt;%=TextBox5.ClientID%&gt;&#39;).value = &#34;&#34;; var checkboxes = $(&#39;#CheckBoxList1&#39;).find(&#39;input[type=&#34;checkbox&#34;]&#39;); for (var i = 0; i &lt; checkboxes.length; i++) { if (checkboxes[i].value == selected) { checkboxes[i].checked = false; } } }); } &lt;/script&gt;</pre> <p><strong><span style="text-decoration: underline;">C#</span></strong></p> <pre class="brush: csharp">protected void CheckBox1_CheckedChanged(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this, this.GetType(), &#34;key&#34;, &#34;window.onload = function() { AlertClear(&#39;&#34; + CheckBoxList1.SelectedValue + &#34;&#39;); };&#34;, true); }</pre> <p><strong><span style="text-decoration: underline;">VB.Net</span></strong></p> <pre class="brush: vb">Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) ScriptManager.RegisterStartupScript(Me, Me.[GetType](), &#34;key&#34;, &#34;window.onload = function() { AlertClear(&#39;&#34; &amp; CheckBoxList1.SelectedValue &amp; &#34;&#39;); };&#34;, True) End Sub</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/gYuYMNH.gif" alt="" width="385" height="237" /></span></strong></p>https://www.aspforums.net:443/Threads/119884/Clear-ASPNet-TextBox-value-and-CheckBoxList-selection-on-jQuery-Sweet-alert-Ok-Button-Click-using-C-and-VBNet/https://www.aspforums.net:443/Threads/119884/Clear-ASPNet-TextBox-value-and-CheckBoxList-selection-on-jQuery-Sweet-alert-Ok-Button-Click-using-C-and-VBNet/Mon, 19 Nov 2018 04:00:26 GMT