请问asp.net怎么实现登陆后隐藏指定div
<divid="header_right_r"><divID="div1"runat="server"></div><divID="div2"runat="server"...
<div id="header_right_r">
<div ID="div1" runat="server">
</div>
<div ID="div2" runat="server">
</div>
</div>
上面是前台div
下面是后台代码,请问怎么才能隐藏
protected void Page_Load(object sender, EventArgs e)
{
if (Session["用户编号"] == null)
{
this.div1.Visible = false;
this.div2.Visible = true;
}
else
{
this.div1.Visible = true;
this.div2.Visible = false;
} 展开
<div ID="div1" runat="server">
</div>
<div ID="div2" runat="server">
</div>
</div>
上面是前台div
下面是后台代码,请问怎么才能隐藏
protected void Page_Load(object sender, EventArgs e)
{
if (Session["用户编号"] == null)
{
this.div1.Visible = false;
this.div2.Visible = true;
}
else
{
this.div1.Visible = true;
this.div2.Visible = false;
} 展开
展开全部
div隐藏的方式不是使用Visible 属性,而是使用CSS来进行控制。
前台代码:
<div id="header_right_r">
<div ID="div1" <%=show1 %>>
</div>
<div ID="div2" <%=show2 %>>
</div>
</div>
后台:
public string show1="",show2="";
protected void Page_Load(object sender, EventArgs e)
{
if (Session["用户编号"] == null)
{
show1 = " style=\"display:none\"";
show2 = " style=\"display:block\"";
}
else
{
show1 = " style=\"display:block\"";
show2 = " style=\"display:none\"";
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询