// the buttons act like a panel tab*
<asp:button ID=Button1> = hide the panel2, show the panel1
<asp:button ID=Button2> = hide the panel1, show the panel2
<asp:panel ID: panel1>
Contents of Panel 1. This is the default
</asp:panel>
<asp:panel ID: panel2>
Contents of Panel 2
<asp:button ID=Save> *response redirect to same page
</asp:panel>
The default view of the page is to show Panel1
.
How can I stay the view on Panel2
after postback when hitting the save button? It keeps returning to Panel1
view.
Any help/tips are appreciated. Thank you!
try this code..
<asp:Button runat="server" ID="Button1" Text="Button1" OnClick="Button1_Click" />
<%--= hide the panel2, show the panel1 --%>
<asp:Button runat="server" ID="Button2" Text="Button2" OnClick="Button2_Click" />
<%--= hide the panel1, show the panel2--%>
<asp:Panel runat="server" ID="panel1">
Contents of Panel 1. This is the default
</asp:Panel>
<asp:Panel runat="server" ID="panel2">
Contents of Panel 2
<asp:Button runat="server" Text="Save" ID="Save" OnClick="Save_Click"/>
</asp:Panel>
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
panel1.Visible = true;
panel2.Visible = false;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
panel1.Visible = true;
panel2.Visible = false;
}
protected void Button2_Click(object sender, EventArgs e)
{
panel1.Visible = false;
panel2.Visible = true;
}
protected void Save_Click(object sender, EventArgs e)
{
panel1.Visible = false;
panel2.Visible = true;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.