【发布时间】:2013-12-17 09:17:14
【问题描述】:
我想知道您将如何显示,然后隐藏有关页面状态的 div。
例如,我有一个上传按钮,一旦文件上传,我希望页面切换到下一个方法,这将显示另一个“页面”并从需要的内容中提取相关信息。
我当前的“视图状态”代码是
<script runat="server">
//This template is being built to allow the viewstates to be displayed and allow them to be hidden
//or shown at the same time. The buttons are being added so we can test whether they will
//be hidden on page use
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string viewStateDisplay = "ViewState 2 is now being displayed";
if (ViewState["PageState"] == null)
{
ViewState["PageState"] = viewStateDisplay;
}
}
}
//button that shows the label string
protected void btnClick_Click(object sender, EventArgs e)
{
lblString.Text = ViewState["PageState"].ToString();
lblString.Visible = true;
}
//button that hides the div, changing "lblstring" or adding more should be able to hide
//or show whatever methods / objects we want
private void Close(object sender, EventArgs e)
{
lblString.Visible = !lblString.Visible;
lblString.Visible = false;
}
</script>
<!-- The following section will include all the html and forms etc !-->
<div>
ViewState Data: <b><asp:Label ID="lblString" runat="server"/></b>
<asp:Button ID="btnClick" runat="server" Text="Get ViewState Data" OnClick="btnClick_Click"/>
<asp:Button ID="Closeform" runat="server" Text ="Hide PageState" OnClick="Close" />
</div>
我觉得我必须将两个步骤都设置为 false,然后根据我希望它出现的位置为每个方法设置一个数字。
如
If request ("thing") then methodName
end if
if request ("second thing") then viewstate new method
if nothing viewstate 1
step1.visible = false
step2.visible = false
但我不确定如何将其转换为可行的 C# 代码,使用我的原始代码并在其中实现我自己的方法,感谢帮助,谢谢。
【问题讨论】: