jQuery to Show Hide controls placed inside Div based on Asp.net Checkbox check uncheck

  ASP.NET Projects

Complete ASPX HHTML Source Codes:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default7.aspx.cs" Inherits="Default7" %>

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script src="//code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#<%=cbAlternateEmail.ClientID%>').bind('click', function () {
                if ($(this).is(":checked")) {
                    //Show the div
                else {
                    //Hide the div
                    //Clear textbox
                    $('#<%=txtAlternateEmail.ClientID %>').val('');
                    //Set focus in textbox
                    $('#<%=txtAlternateEmail.ClientID %>').focus();

    <form id="form1" runat="server">
        <fieldset style="width: 270px;">
            <legend>Show/Hide Div Content Demo</legend>
            <asp:CheckBox ID="cbAlternateEmail" runat="server" Text="Alternate Email ?" />
            <div id="dvShowHide" style="display: none;">
                Enter Email Id :<asp:TextBox ID="txtAlternateEmail" runat="server"></asp:TextBox><br />


(Visited 14 times, 1 visits today)