我有一个主页:
<asp:UpdatePanel ID="upPanel" runat="server">
<ContentTemplate>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
此外,我还有3个页面,其中包含导航按钮“下一步”和“后退”,如下所示:
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div>
<asp:Label ID="lbl1" runat="server">Second PAGE</asp:Label>
<asp:Button ID="btnBack" runat="server" />
<asp:Button ID="btnNext" runat="server" />
</div>
</asp:Content>
请问您,如何在不加载所有页面且仅加载内容的情况下在这些页面之间导航?
答案 0 :(得分:0)
您可以在ContentPlaceHolderContent
和btnNext
btnBack
次活动中OnClick
添加和删除控件
<强>标记:强>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:UpdatePanel ID="upPanelContent" runat="server">
<asp:contentplaceholder id="ContentPlaceHolderContent" runat="server" />
</asp:UpdatePanel>
<asp:Button ID="btnBack" runat="server" OnClick="btnBack_Click"/>
<asp:Button ID="btnNext" runat="server" OnClick="btnNext_Click"/>
</asp:Content>
<强>代码隐藏:强>
protected btnNext_Click(Object sender, EventArgs e)
{
ContentPlaceHolderContent.Controls.Clear();
Literal l = new Literal();
l.Text = "new content";
ContentPlaceHolderContent.Controls.Add(l);
}
protected void btnBack_Click(Object sender, EventArgs e)
{
ContentPlaceHolderContent.Controls.Clear();
Literal l = new Literal();
l.Text = "old content";
ContentPlaceHolderContent.Controls.Add(l);
}