这个不能使用 JS 来控件。
你是使用ASP.NET吧,ASP.NET里很控件实现。把登录的界面放在一个 Panel 控件里,把导航栏的内容放在另外一个 Panel 里面。然后在后台代码中判断用户是否登录,如果登记,就把导航栏所在的 Panel 显示,并把登录所在的 Panel 隐藏。

解决方案 »

  1.   

    簡單做一個,你參考參考//index.aspx<%@ Page language="c#" Codebehind="index.aspx.cs" AutoEventWireup="false" Inherits="javascriptAsp.net.index" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>index</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <FONT face="新細明體">
    <asp:Panel id="Panel1" style="Z-INDEX: 101; LEFT: 32px; POSITION: absolute; TOP: 160px" runat="server"
    Width="216px" Height="128px">
    <P>&nbsp;</P>
    <P>UID
    <asp:TextBox id="TextBox1" runat="server"></asp:TextBox></P>
    <P>pwd
    <asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
    <asp:Button id="Button1" runat="server" Text="Login"></asp:Button></P>
    </asp:Panel>
    <asp:Panel id="Panel2" style="Z-INDEX: 102; LEFT: 32px; POSITION: absolute; TOP: 160px" runat="server"
    Width="216px" Height="128px">&nbsp;
    <asp:Label id="Label1" runat="server">Label</asp:Label></asp:Panel></FONT>
    </form>
    </body>
    </HTML>
    //index.aspx.csusing System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;namespace javascriptAsp.net
    {
    /// <summary>
    /// Summary description for index.
    /// </summary>
    public class index : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.Panel Panel1;
    protected System.Web.UI.WebControls.Panel Panel2;
    protected System.Web.UI.WebControls.TextBox TextBox1;
    protected System.Web.UI.WebControls.TextBox TextBox2;
    protected System.Web.UI.WebControls.Label Label1;
    protected System.Web.UI.WebControls.Button Button1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    if(Session["Loginner"]!=null)
    {
    this.Panel2.Visible = true;
    this.Panel1.Visible = false;
    }
    else
    {
    this.Panel2.Visible = false;
    this.Panel1.Visible = true;
    }
    // Put user code to initialize the page here
    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {    
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void Button1_Click(object sender, System.EventArgs e)
    {
    this.Panel1.Visible = false;
    this.Panel2.Visible = true;
    Session["Loginner"] = this.TextBox1.Text;
    this.Label1.Text = this.TextBox1.Text+"登陸成功!";
    }
    }
    }
      

  2.   

    exboy(kuku) 说的方法我已经试过了,就是利用PANEL,可是不行啊,有页面从数据库中读出了数据!显示出来了,可是panel1和panel2一实现隐藏和可见,那些DATALIST中的数据就不见了!
      

  3.   

    ghtyan() 和我用的方法是一样的!
      

  4.   

    请问下,可否做成用户控件呢?再在每个页引用,怎样能不干扰到别的数据呢?我是用AspNetPager分页的!