100分,求高手帮忙!

giantboy520 2006-03-25 02:59:09
我是一个初学者,我想问一下,我想在网站的左边弄一个登陆框,如果用户登陆的话,在登陆框的地方显示用户登陆后的用户选项,也就是用户导航列表,而登陆框消失。(在此同时不影响同一页面别的数据!我用C#做的B/S)请问用JAVASCRIPT怎么实现啊?最好能给个实例!谢谢了!
...全文
72 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
jbeauty 2006-04-16
  • 打赏
  • 举报
回复
已经自己解决了
giantboy520 2006-03-25
  • 打赏
  • 举报
回复
请问下,可否做成用户控件呢?再在每个页引用,怎样能不干扰到别的数据呢?我是用AspNetPager分页的!
giantboy520 2006-03-25
  • 打赏
  • 举报
回复
ghtyan() 和我用的方法是一样的!
giantboy520 2006-03-25
  • 打赏
  • 举报
回复
exboy(kuku) 说的方法我已经试过了,就是利用PANEL,可是不行啊,有页面从数据库中读出了数据!显示出来了,可是panel1和panel2一实现隐藏和可见,那些DATALIST中的数据就不见了!
ghtyan 2006-03-25
  • 打赏
  • 举报
回复
簡單做一個,你參考參考

//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> </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"> 
<asp:Label id="Label1" runat="server">Label</asp:Label></asp:Panel></FONT>
</form>
</body>
</HTML>


//index.aspx.cs

using 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+"登陸成功!";
}
}
}
wen1818 2006-03-25
  • 打赏
  • 举报
回复
根据条件设置web控件的visibe
exboy 2006-03-25
  • 打赏
  • 举报
回复
这个不能使用 JS 来控件。
你是使用ASP.NET吧,ASP.NET里很控件实现。

把登录的界面放在一个 Panel 控件里,把导航栏的内容放在另外一个 Panel 里面。

然后在后台代码中判断用户是否登录,如果登记,就把导航栏所在的 Panel 显示,并把登录所在的 Panel 隐藏。

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧