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.Crate On Off Toggle Button using CheckBox in ASP.Net<p>Hi <a class="username" rel="nid@patel"> nid@patel</a>,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">HTML</span></strong></p> <pre class="brush: html">&lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head runat=&#34;server&#34;&gt; &lt;title&gt;&lt;/title&gt; &lt;style type=&#34;text/css&#34;&gt; .switch { position: relative; display: inline-block; width: 50px; height: 24px; } .switch input { opacity: 0; } .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; -webkit-transition: .4s; transition: .4s; } .slider:before { position: absolute; content: &#34;&#34;; height: 16px; width: 16px; left: 4px; bottom: 4px; background-color: white; -webkit-transition: .4s; transition: .4s; } input:checked + .slider { background-color: #2196F3; } input:focus + .slider { box-shadow: 0 0 1px #2196F3; } input:checked + .slider:before { -webkit-transform: translateX(26px); -ms-transform: translateX(26px); transform: translateX(26px); } /* Rounded sliders */ .slider.round { border-radius: 34px; } .slider.round:before { border-radius: 50%; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&#34;form1&#34; runat=&#34;server&#34;&gt; &lt;center&gt; &lt;label class=&#34;switch&#34;&gt; &lt;asp:CheckBox ID=&#34;chkOnOff&#34; runat=&#34;server&#34; Checked=&#34;true&#34; /&gt; &lt;span class=&#34;slider round&#34;&gt;&lt;/span&gt; &lt;/label&gt; &lt;asp:Button ID=&#34;Button1&#34; Text=&#34;Save&#34; runat=&#34;server&#34; OnClick=&#34;Save&#34; /&gt; &lt;/center&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p><strong><span style="text-decoration: underline;">C#</span></strong></p> <pre class="brush: csharp">protected void Save(object sender, EventArgs e) { string onOff = chkOnOff.Checked ? &#34;On&#34; : &#34;Off&#34;; ClientScript.RegisterClientScriptBlock(this.GetType(), &#34;&#34;, &#34;alert(&#39;&#34; + onOff + &#34;&#39;)&#34;, true); }</pre> <p><span style="text-decoration: underline;"><strong>VB.Net</strong></span></p> <pre class="brush: vb">Protected Sub Save(ByVal sender As Object, ByVal e As EventArgs) Dim onOff As String = If(chkOnOff.Checked, &#34;On&#34;, &#34;Off&#34;) ClientScript.RegisterClientScriptBlock(Me.GetType(), &#34;&#34;, &#34;alert(&#39;&#34; &amp; onOff &amp; &#34;&#39;)&#34;, True) End Sub</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><img src="https://i.imgur.com/eIDUlYT.gif" alt="" width="180" height="151" /></p>https://www.aspforums.net:443/Threads/189346/Crate-On-Off-Toggle-Button-using-CheckBox-in-ASPNet/https://www.aspforums.net:443/Threads/189346/Crate-On-Off-Toggle-Button-using-CheckBox-in-ASPNet/Mon, 19 Aug 2019 03:31:29 GMT