[英]ASP.NET Panel return to a certain panel after postback
// 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>
頁面的默認視圖是顯示Panel1
。
點擊保存按鈕后,如何在回發后將視圖保留在Panel2
上? 它一直返回到Panel1
視圖。
任何幫助/提示表示贊賞。 謝謝!
試試這個代碼..
<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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.