Show Hide different ASP.Net Panel on Button Click using C# and VB.Net

muhammad12
 
on Jan 02, 2022 11:03 PM
648 Views

Hi arjunv,

I have many button on webform side bar. I want when i click on button webform appear on same page. 

Please help me how can i do this.

Login

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="DispatchSystem.login" %>
 
<!DOCTYPE html>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="lblname" runat="server" Text="Name">
            <asp:TextBox ID="txtname" runat="server"></asp:TextBox>
        </asp:Label><asp:Label ID="lblpass" runat="server" Text="Password"></asp:Label>
        <asp:TextBox ID="txtpass" runat="server" TextMode="Password" ></asp:TextBox>
        <asp:Button ID="btnlogin" runat="server" Text="login" OnClick="btnlogin_Click" />
    </div>
    </form>
</body>
</html>

Where I use different button in panel on left side. I want when I click on button on right side web form of that button will appear.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DispatchHomePage.aspx.cs" Inherits="DispatchSystem.DispatchHomePage" %>
 
<!DOCTYPE html>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">     
        <asp:Panel ID="Panel1" runat="server" Height="470px" HorizontalAlign="Left" Width="156px">
            <br/>
            <br/>
            <br/> 
            <br/>
            <asp:Button ID="Button1" runat="server" Text="IT Equipment" OnClick="Button1_Click" />
            <br />
            <asp:Button ID="Button2" runat="server" Text="Procurement" OnClick="Button2_Click" />
        </asp:Panel>     
    </form>
</body>
</html>

when i click on button1 then the will be show on right side like.

to:  ..........

dept:........

city.......

 from:..........

dept:...... 

city:.......

Download FREE API for Word, Excel and PDF in ASP.Net: Download
arjunv
 
on Jan 04, 2022 05:06 AM

Hi 

Please refer below Sample.

HTML

<asp:Panel ID="Panel1" runat="server" Height="470px" HorizontalAlign="Left" Width="156px" Style="float: Left">
    <br />
    <br />
    <br />
    <br />
    <asp:Button ID="btnItEquipments" runat="server" Text="IT Equipment" OnClick="IT_Equipment" />
    <br />
    <asp:Button ID="Button2" runat="server" Text="Procurement" OnClick="Procurement" />
</asp:Panel>
<asp:Panel ID="pnlMain" runat="server" Style="float: left">
    <asp:Panel ID="pnl" runat="server">
        <asp:Label ID="lblItEwuipments" runat="server" Visible="false" BorderColor="Black" BorderWidth="1px" BackColor="Red">
        IT Equipment means all computers, servers, printers, computer hardware, wired or mobile telephones,
        <br />
        on-site process control and automation systems, telecommunication assets, and other information technology-related equipment.
        </asp:Label>
        <br />
        <br />
        <br />
        <asp:Label ID="lblprocurment" runat="server" Visible="false" BorderColor="Black" BorderWidth="1px" BackColor="Yellow">
        Procurement is the process of purchasing goods or services and is usually in reference to business spending.
        <br />
        Business procurement requires preparation, solicitation, and payment processing, which usually involves several areas of a company.
        </asp:Label>
    </asp:Panel>
</asp:Panel>

Code

C#

protected void IT_Equipment(object sender, EventArgs e)
{
    lblItEwuipments.Visible = true;
    lblprocurment.Visible = false;
}

protected void Procurement(object sender, EventArgs e)
{
    lblprocurment.Visible = true;
    lblItEwuipments.Visible = false;
}

VB.Net

Protected Sub IT_Equipment(ByVal sender As Object, ByVal e As EventArgs)
    lblItEwuipments.Visible = True
    lblprocurment.Visible = False
End Sub

Protected Sub Procurement(ByVal sender As Object, ByVal e As EventArgs)
    lblprocurment.Visible = True
    lblItEwuipments.Visible = False
End Sub

Screenshot