(1)用户未登录时(未登录时是否显示“会员中心”按钮,根据你的情况而定):
(2)用户登录后:
下面给出具体代码(针对1.0版本):
(1)在需要放置横向用户登录窗口的地方加入如下代码(通常写在“网站顶部”标签的合适位置),以下代码中蓝色部分为修正时新添加的代码:
<div style="margin:5px; height:23px; width:240px; overflow:hidden;">
<iframe id="user_login_window" frameborder="0" src="/Login.aspx" scrolling="auto" allowtransparency="true"></iframe>
</div>
(2)修改根目录下的Login.aspx文件成下面的代码(红色部分为修改代码,绿色部分为添加代码),你可以直接Copy过去用就可以了:
<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Login.aspx.cs" Inherits="PowerEasy.WebSite.Login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>会员登录</title>
<link href="Skin/Default/user.css" rel="stylesheet" type="text/css" />
</head>
<body id="user_login">
<form id="form1" runat="server">
<asp:Panel ID="PnlLogin" runat="server">
<asp:TextBox Visible="false" ID="TxtUserName" MaxLength="20" Width="95" runat="server"></asp:TextBox>
<asp:TextBox Visible="false" ID="TxtPassword" runat="server" Width="95" TextMode="Password"></asp:TextBox>
<asp:PlaceHolder ID="PhValCode" runat="server">
<asp:TextBox ID="TxtValidateCode" MaxLength="6" Width="60" runat="server" onfocus="this.select();"></asp:TextBox> <pe:ValidateCode ImageAlign="AbsMiddle" ID="VcodeLogin" runat="server" RefreshLinkToolTip="看不清楚,换一个" />
</asp:PlaceHolder>
<asp:Button ID="BtnLogin" Visible="false" runat="server" Text="登录" OnClick="BtnLogin_Click" />
<a class="bt_login" href="User/Default.aspx" title="进入会员中心" target="_top">会员中心</a>
<a class="bt_login" href="User/Login.aspx" title="还不是河北宠物网的客户?马上注册吧" target="_top">登 录</a>
<a class="bt_login" href="User/Register.aspx" title="只有登录河北宠物网会员中心,您才有权利进行一些功能操作哦" target="_top">注 册</a>
<pe:RequiredFieldValidator ID="ValrUserName" runat="server" ErrorMessage="请输入用户名!"
ControlToValidate="TxtUserName" Display="None" SetFocusOnError="True"></pe:RequiredFieldValidator>
<pe:RequiredFieldValidator ID="ValrPassword" runat="server" ErrorMessage="请输入密码!"
ControlToValidate="TxtPassword" Display="None" SetFocusOnError="True"></pe:RequiredFieldValidator>
<pe:RequiredFieldValidator ID="ValrValidateCode" runat="server" ErrorMessage="请输入验证码!"
ControlToValidate="TxtValidateCode" Display="None" SetFocusOnError="True"></pe:RequiredFieldValidator>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
ShowSummary="False" />
</asp:Panel>
<asp:Panel ID="PnlLoginStatus" runat="server">
<div id="welcome">
<asp:Literal ID="LitUserName" runat="server"></asp:Literal>,您好!
</div>
<a class="bt_login" href="User/Default.aspx" title="到会员中心查看各种信息" target="_top">会员中心</a>
<a class="bt_login" href="User/Logout.aspx" title="欢迎你再次光临河北宠物网" target="_top">退出登录</a>
<asp:Literal Visible="false" ID="LitMoney" runat="server">0</asp:Literal>
<asp:Literal Visible="false" ID="LitUserExp" runat="server">0</asp:Literal>
<asp:Literal Visible="false" ID="LitMessage" runat="server">0</asp:Literal>
<asp:Literal Visible="false" ID="LitLoginTime" runat="server">0</asp:Literal>
<asp:Literal Visible="false" ID="LitPoint" runat="server">0</asp:Literal>
<asp:Literal Visible="false" ID="LitSignin" runat="server">0</asp:Literal>
</asp:Panel>
<asp:Panel ID="PnlLoginMessage" runat="server" Visible="false">
<asp:Literal ID="LitErrorMessage" runat="server"></asp:Literal>
<asp:Button ID="BtnReturn" runat="server" Text="返回" OnClick="BtnReturn_Click" />
</asp:Panel>
</div>
</form>
</body>
</html>
(3)修改/Skin/Default/user.css文件(主要是修改其中的/* 匿名用户投稿链接 */这部分,红色为添加部分,绿色为修改部分):
/* 匿名用户投稿链接 */
#user_login {
background:transparent;
}
#welcome {
float:left;
height:23px;
line-height:23px;
}
.bt_login {
margin: 0px 5px;
display: block;
width: 67px;
height: 23px;
line-height: 23px;
text-align: center;
color: #718cb0;
background: url(Images/bt_login.gif) center 0px no-repeat;
cursor: pointer;
float:left;
}
.bt_login:hover {
color: #ffffff;
background: url(Images/bt_login.gif) center -23px no-repeat;
}
可参考网站:http://www.30m.cn
升级到1.1后--SF1.1中的横向用户登录解决方案
实际上非常简单,只要对比SF1.1中自带的Login.aspx文件与SF1.0中的Login.aspx文件两者不同,作出些改动即可,呵,为了图省事,我直接给出所做出改动的UserLogin.aspx文件内容。(具体内容请先阅读本文的主题贴,即上面的修改)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="PowerEasy.WebSite.LogOn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>会员登录</title>
<link href="Skin/Default/user.css" rel="stylesheet" type="text/css" />
</head>
<body id="LoginStatusbody">
<form id="form1" runat="server">
<asp:Panel ID="PnlLogOn" runat="server">
<asp:TextBox Visible="false" ID="TxtUserName" MaxLength="20" Width="95" runat="server"></asp:TextBox>
<asp:TextBox Visible="false" ID="TxtPassword" runat="server" Width="95" TextMode="Password"></asp:TextBox>
<asp:PlaceHolder ID="PhValCode" runat="server">
<asp:TextBox ID="TxtValidateCode" MaxLength="6" Width="60" runat="server" onfocus="this.select();"></asp:TextBox>
<pe:ValidateCode ImageAlign="AbsMiddle" ID="VcodeLogOn" runat="server" RefreshLinkToolTip="看不清楚,换一个" />
</asp:PlaceHolder>
<asp:DropDownList Visible="false" ID="DropExpiration" runat="server">
<asp:ListItem Value="None" Text="不保存"></asp:ListItem>
<asp:ListItem Value="Day" Text="保存一天"></asp:ListItem>
<asp:ListItem Value="Month" Text="保存一月"></asp:ListItem>
<asp:ListItem Value="Year" Text="保存一年"></asp:ListItem>
</asp:DropDownList>
<asp:Button Visible="false" ID="BtnLogOn" runat="server" Text="登录" OnClick="BtnLogOn_Click" />
<a class="bt_login" href="User/Default.aspx" title="进入会员中心" target="_top">会员中心</a>
<a class="bt_login" href="User/Login.aspx" title="还不是河北宠物网的客户?马上注册吧" target="_top">登 录</a>
<a class="bt_login" href="User/Register.aspx" title="只有登录河北宠物网会员中心,您才有权利进行一些功能操作哦" target="_top">注 册</a>
<div class="clearbox">
</div>
<pe:RequiredFieldValidator ID="ValrUserName" runat="server" ErrorMessage="请输入用户名!"
ControlToValidate="TxtUserName" Display="None" SetFocusOnError="True"></pe:RequiredFieldValidator>
<pe:RequiredFieldValidator ID="ValrPassword" runat="server" ErrorMessage="请输入密码!"
ControlToValidate="TxtPassword" Display="None" SetFocusOnError="True"></pe:RequiredFieldValidator>
<pe:RequiredFieldValidator ID="ValrValidateCode" runat="server" ErrorMessage="请输入验证码!"
ControlToValidate="TxtValidateCode" Display="None" SetFocusOnError="True"></pe:RequiredFieldValidator>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
ShowSummary="False" />
</asp:Panel>
<asp:Panel ID="PnlLogOnStatus" runat="server">
<div class="welcome">
<div id="welcome">
<asp:Literal ID="LitUserName" runat="server"></asp:Literal>,您好!
</div>
<a class="bt_login" href="User/Default.aspx" title="到会员中心查看各种信息" target="_top">会员中心</a>
<a class="bt_login" href="User/Logout.aspx" title="欢迎你再次光临河北宠物网" target="_top">退出登录</a>
<asp:Literal Visible="false" ID="LitMoney" runat="server">0</asp:Literal>
<asp:Literal Visible="false" ID="LitUserExp" runat="server">0</asp:Literal>
<pe:ExtendedLiteral HtmlEncode="false" ID="LitMessage" runat="server">0</pe:ExtendedLiteral>
<asp:Literal Visible="false" ID="LitLogOnTime" runat="server">0</asp:Literal>
<asp:Literal Visible="false" ID="LitPoint" runat="server">0</asp:Literal><br />
<asp:Literal Visible="false" ID="LitSignIn" runat="server">0</asp:Literal><br />
</div>
</asp:Panel>
<asp:Panel ID="PnlLogOnMessage" runat="server" Visible="false">
<pe:ExtendedLiteral HtmlEncode="false" ID="LitErrorMessage" runat="server"></pe:ExtendedLiteral>
<asp:Button ID="BtnReturn" runat="server" Text="返回" OnClick="BtnReturn_Click" />
</asp:Panel>
</form>
</body>
</html>
为了方便大家,下面给出UserLogin.aspx文件的附件:
感谢mice110提供,论坛地址:http://bbs.powereasy.net/dispbbs.asp?boardid=73&id=366497