But the guarantee does not jump page, can Baidu this effect is after jump. In other words, I had to make two sets of effects on the same page, so I thought about the implementation of the control's explicit concealment. After exploring, there are two ways to solve this problem:
One, using the panel as a container can use the ASP Control Panel as a container, and then use other ASP control with the implementation, this is the most convenient, the code is as follows:
Panel1:
[HTML]View PlainCopy
- <span style=><asp:panel ID=< Span class= "Attribute-value" > "Panel1" runat= "server" font-size= "Medium" >
- <span id= "SayHello" > Hello, <span><%=session["UserName"] % ></span> </span>
- <asp:HyperLink id= "hlpersonalspace" runat= "server" navigateurl= "~/needhelpspace.aspx" target= "_self" > personal space </asp:hyperlink>
- <asp:hyperlink id="Hlinfo" runat="Server"> Message </asp:hyperlink>
- <Asp:linkbutton id="Hlquit" runat="Server" onclick="Hlquit_click " > Exit </Asp:linkbutton>
- </asp:panel></span>
Panel2:
[HTML]View PlainCopy
- <span style="FONT-SIZE:14PX;" ><asp:panel id="Panel2" runat="Server" font-size="Medium">
- Hello, visitor.
- <a href= "#" onclick= "$ (' #w '). Window (' open ')" > login </ a>
- <asp:HyperLink id= "Hlregister" runat= "server" navigateurl= ~/ Register.aspx " target=" _blank " > Register </asp:hyperlink>
- <asp:hyperlink id="Hlsearch" runat="Server"> Help </asp:hyperlink >
- </asp:panel></span>
Background code:
[CSharp]View PlainCopy
- <span style="FONT-SIZE:14PX;" > if (session["UserName"] = = null)
- {
- Panel2.visible = true;
- Panel1.visible = false;
- }
- Else
- {
- Panel1.visible = true;
- Panel2.visible = false;
- }</span>
Second, use Div as container
But I am here because of the use of the master, and the ASP control must be placed in the server-side form, this may cause a conflict with the child page, resulting in a page with two server-side form. Therefore, the HTML control needs to be changed. The way I use it here is to put the relevant HTML controls and tags in the div, but the div must add runat= "Server" before interacting with the background. You can also use JS directly to the DIV's explicit control, the code is as follows:
DIV1:
[HTML]View PlainCopy
- <span style="FONT-SIZE:14PX;" ><div id="Loginbefore" runat ="Server" style="Font-size:medium" >
- <span id= "topuser" style="padding-right:25px;" > Hello tourists
- <a href="javascript:void (0)" onclick="$ (' #w '). Window (' open ') '> Login </A >
- <a href="register.aspx"> Register </a>
- <a href="#"> Search </a>
- </span>
- </div></span>
DIV2:
[HTML]View PlainCopy
- <span style="FONT-SIZE:14PX;" ><div id= "loginafter" runat= "server" style= "font-size:medium " >
- < span id= "TopUser1" < span class= "attribute" >style= "padding-right:25px;" > Hello, <span> <%=session["UserName"] %></ span> |
- <a href= "userloglist.aspx?id=<%=session[" UserID"]%>" > Personal Space </a > |
- <a href="unreademail.aspx"> Message </a> |
- <a href="#" onclick="Loginquit ()"> Exit </a>
- </span>
- </div></span>
C # Background Call method:
[HTML]View PlainCopy
- <span style="FONT-SIZE:14PX;" > if (session["UserName"] = = null)
- {
- loginbefore.style["Display"] = "Block";
- loginafter.style["Display"] = "None";
- }
- Else
- {
- loginbefore.style["Display"] = "None";
- loginafter.style["Display"] = "Block";
- }
- </span>
If you use JS to call directly, you can manipulate the method of Div explicit is as follows:
[HTML]View PlainCopy
- <span style="FONT-SIZE:14PX;" > document.getElementById ("Loginafter"). Style.display = "None";//Hide
- document.getElementById ("Loginbefore"). Style.display = "block";//Display </span>
The effect of the final implementation is as follows:
Figure 3: Before landing
Figure 4: After landing
Display hiding methods for controls