我必须在后面的代码中向我的项目母版页添加一些控件,但即使在回发后我也想保留它们。我该怎么做?我已经搜索过了,我认为我必须使用 preinit ,但我不知道如何,也不知道母版页是否有 preinit。
<form id="form1" runat="server">
<asp:ScriptManager ID="MainScriptmanager" runat="server" EnablePartialRendering="true" />
<asp:UpdatePanel ID="MasterContentUpdatePanel" runat="server" UpdateMode="conditional">
<ContentTemplate>
<asp:TabContainer ID="MainTabContainer" runat="server" ActiveTabIndex="1" TabStripPlacement="Bottom">
</asp:TabContainer>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
protected void Button1_Click(object sender, EventArgs e)
{
tabCount = tabCount + 1;
AjaxControlToolkit.TabPanel tab = new AjaxControlToolkit.TabPanel();
tab.ID = "tab" + Convert.ToString(tabCount);
tab.HeaderText = "tab" + Convert.ToString(tabCount);
MainTabContainer.Tabs.Add(tab);
}