Replace 'input' with 'asp:checkbox'. Write code at the same time:
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (Card1.Visible == true)
{
Card1.Visible = false;
Card2.Visible = true;
}
else {
Card1.Visible = true;
Card2.Visible = false;
}
}
<body>
<form id="form1" runat="server">
<div class="card" id="Card1" runat="server">
<div class="col-sm-7" style="width: 100%; margin-bottom: 1%;">
<asp:Panel Class="print-contents" ID="pnlContents" runat="server" BorderStyle="Solid" BorderWidth="2" BorderColor="#f0f1f2">
This is card One
<div>
aaaa bbbb
</div>
<asp:Button ID="Button1" runat="server" Text="Button for One" OnClick="Button1_Click" />
</asp:Panel>
</div>
</div>
<div class="card" id="Card2" runat="server" visible="false" >
<div class="col-sm-7" style="width: 100%; margin-bottom: 1%;">
<asp:Panel Class="print-contents" ID="Panel1" runat="server" BorderStyle="Solid" BorderWidth="2" BorderColor="#f0f1f2">
This is Card Two
<div class="wrap">
aaaa bbbb
</div>
<asp:Button ID="Button2" runat="server" Text="Button for Two" OnClick="Button2_Click"/>
</asp:Panel>
</div>
</div>
<br />
<asp:Label ID="Label1" runat="server">Change Orientation</asp:Label>
<div class="input-group">
<label class="switch">
<asp:CheckBox runat="server" AutoPostBack="true" id="CheckBox1" OnCheckedChanged="CheckBox1_CheckedChanged" />
<span class="slider round"></span>
</label>
</div>
</form>
</body>
Output:
Best Regards,
Qi You
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.