【发布时间】:2018-07-29 03:09:11
【问题描述】:
我一直在努力将 TabContainer 保存到将加载该 TabContainer 的所有 TabPanel 的视图状态变量。 (页面加载速度会更快吗?)。 如果问题格式不正确,请原谅我;我还是 asp.net 的新手,这是我的代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CreateTabbedPanel();
Response.Write("New Tabs Loaded");
}
else
{
// Here i would need to load the TabContainer from the viewstate variable
Response.Write("Tabs Loaded from ViewState");
}
}
private void CreateTabbedPanel()
{
TabPanel tp = null;
string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand cmd = new SqlCommand("select Description from TblProductType", con);
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
tp = new TabPanel();
tp.HeaderText = rdr["Description"].ToString();
TabContainer1.Tabs.Add(tp);
}
}
// Here i would need to create the viewstate variable
}
这是我的网络表单:
<form id="form1" runat="server">
<div>
<ajaxToolkit:TabContainer ID="TabContainer2" runat="server"
ActiveTabIndex="1" AutoPostBack="false">
</ajaxToolkit:TabContainer>
</div>
</form>
我需要做什么?
【问题讨论】:
标签: c# asp.net webforms ajaxcontroltoolkit viewstate