大神帮忙看下
前台<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Login.ascx.cs" Inherits="Show_UserControls_Login" %>
<div style="text-align: center">
<table border="3" cellpadding="1" cellspacing="1" style="width: 455px; height: 391px">
<tr>
<td style="background-color: skyblue">
欢迎登录农产品质量检测中心管理后台<asp:Login id="Login1" runat="server" BackColor="Transparent" BorderWidth="0px" OnLoggedIn="Login1_LoggedIn" OnLoginError="Login1_LoginError" OnLoggingIn="Login1_LoggingIn" Height="247px" Width="472px">
<LayoutTemplate>
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="70%">
<tr>
<td width="37%" style="height: 19px">
</td>
<td colspan="2" style="height: 19px">
</td>
</tr>
<tr>
<td colspan="3" style="height: 113px">
<table border="0" cellpadding="0" cellspacing="6" width="100%">
<tr>
<td class="r" width="9%">
</td>
<td class="i" style="width: 86px">
用 户 名</td>
<td align="center" style="width: 100px">
<asp:TextBox id="UserName" runat="server" Width="189px" Height="29px" style="border:1px solid ; font-size:14px" ForeColor="Gray" onclick="show_1();"></asp:TextBox></td>
</tr>
<tr>
<td class="r">
</td>
<td class="i" style="width: 86px">
密 码</td>
<td align="center" style="width: 100px">
<asp:TextBox id="Password" runat="server" textMode="Password" CssClass="e" Height="29px" Width="187px" style="border:1px solid ; font-size:14px"></asp:TextBox></td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="height: 50px" id="TD2" runat="server">
</td>
<td align="center" colspan="2" style="height: 50px" id="TD1" runat="server">
<asp:ImageButton id="Login" CommandName="Login" runat="server" ImageUrl="~/index.files/3.jpg" onMouseOver="ImageChange()" onMouseOut="ImageRestore()"/></td>
</tr>
<tr>
<td colspan="3">
<table border="0" cellpadding="0" cellspacing="5" width="100%">
<tr>
<td style="height: 2px">
<img height="2" src="index.files/4.jpg" width="173" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="height: 29px">
</td>
<td style="height: 29px" width="17%">
<img height="29" src="index.files/5.jpg" width="29" /></td>
<td align="center" class="e" style="height: 29px; width: 54%;">
<span style="font-size: 9pt; color:White">管理员登录</span></td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
</td>
</tr>
</table>
</div>
后台
public partial class Show_UserControls_Login : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Login1_LoggedIn(object sender, EventArgs e)
{
if (Roles.IsUserInRole(Login1.UserName, "Office1"))
{
Response.Redirect("~/Management/Office1/Default.htm");
}
else if (Roles.IsUserInRole(Login1.UserName, "Office2"))
{
Response.Redirect("~/Management/Office2/Default.htm");
}
else if (Roles.IsUserInRole(Login1.UserName, "Office3"))
{
Response.Redirect("~/Management/Office3/Default.htm");
}
else if (Roles.IsUserInRole(Login1.UserName, "Office4"))
{
Response.Redirect("~/Management/Office4/Default.htm");
}
else if (Roles.IsUserInRole(Login1.UserName, "Office5"))
{
Response.Redirect("~/Management/Office5/Default.htm");
}
else if (Roles.IsUserInRole(Login1.UserName, "Office6"))
{
Response.Redirect("~/Management/Office6/Default.htm");
}
else if (Roles.IsUserInRole(Login1.UserName, "Office7"))
{
Response.Redirect("~/Management/Office7/Default.htm");
}
else if (Roles.IsUserInRole(Login1.UserName, "Admin"))
{
Response.Redirect("~/Management/Admin/Default.aspx");
}
else
{
Response.Redirect("~/UnAuthorization.aspx");
}
}
protected void Login1_LoginError(object sender, EventArgs e)
{
Response.Redirect("~/Login_Error.aspx");
}
protected void Login1_LoggingIn(object sender, LoginCancelEventArgs e)
{
try
{
MembershipUser u = Membership.GetUser(Login1.UserName);
bool flag = u.IsLockedOut;
if (flag)
{
u.UnlockUser();
}
}
catch
{
}
}
}
出现缺少对象的错误 --------------------编程问答-------------------- 单步调试,看哪里报错,然后对症下药 --------------------编程问答-------------------- 自己已解决哈 --------------------编程问答-------------------- --------------------编程问答-------------------- 下次上代码之前把错误信息也赋上来:
这就像伸一支脚叫别人猜里面的哪根腿手是被电吹风吹过一样。 --------------------编程问答-------------------- 嗯,是的,谢谢啦
补充:.NET技术 , C#