我向页面拖拽了一个LOGIN控件,然后模板化,修改,得到下面的代码
<asp:Login ID="Login1" runat="server" BackColor="White" BorderColor="Green" BorderPadding="4" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#333333" TextLayout="TextOnTop">
<TitleTextStyle BackColor="#990000" Font-Bold="True" Font-Size="0.9em" ForeColor="White" />
<InstructionTextStyle Font-Italic="True" ForeColor="Black" />
<TextBoxStyle Font-Size="0.8em" />
<LoginButtonStyle BackColor="White" BorderColor="#CC9966" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Verdana" Font-Size="0.8em" ForeColor="#990000" />
<LayoutTemplate>
<table border="0" cellpadding="4" cellspacing="0" style="border-collapse: collapse">
<tr>
<td style="height: 186px">
<table border="0" cellpadding="0">
<tr>
<td align="center" style="font-weight: bold; font-size: 0.9em; color: white; height: 28px;
background-color: #008f00">
后 台 登 录</td>
</tr>
<tr>
<td>
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">用户名:</asp:Label></td>
</tr>
<tr>
<td>
<asp:TextBox ID="UserName" runat="server" Font-Size="0.8em"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
ErrorMessage="必须填写“用户名”。" ToolTip="必须填写“用户名”。" ValidationGroup="Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">密码:</asp:Label></td>
</tr>
<tr>
<td>
<asp:TextBox ID="Password" runat="server" Font-Size="0.8em" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
ErrorMessage="必须填写“密码”。" ToolTip="必须填写“密码”。" ValidationGroup="Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="RememberMe" runat="server" Text="下次记住我。" />
</td>
</tr>
<tr>
<td align="center" style="color: red">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
<tr>
<td align="right">
<asp:Button ID="LoginButton" runat="server" BackColor="Transparent" BorderColor="Green"
BorderStyle="Solid" BorderWidth="1px" CommandName="Login" Font-Names="Verdana"
Font-Size="0.8em" ForeColor="Green" Height="26px" OnClick="LoginButton_Click"
Text="登 录" ValidationGroup="Login1" Width="82px" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>现在我想通过他们实现登录功能,我所写的.aspx.cs的代码是
protected void LoginButton_Click(object sender, EventArgs e)
{
string user_name = Request.Params["UserName"];
string user_pwd = Request.Params["Password"];
Response.Write(user_name);
Response.Write(user_pwd);
}我发现获取不到这些相关的值,请问正确的写法是?谢谢
<asp:Login ID="Login1" runat="server" BackColor="White" BorderColor="Green" BorderPadding="4" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#333333" TextLayout="TextOnTop">
<TitleTextStyle BackColor="#990000" Font-Bold="True" Font-Size="0.9em" ForeColor="White" />
<InstructionTextStyle Font-Italic="True" ForeColor="Black" />
<TextBoxStyle Font-Size="0.8em" />
<LoginButtonStyle BackColor="White" BorderColor="#CC9966" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Verdana" Font-Size="0.8em" ForeColor="#990000" />
<LayoutTemplate>
<table border="0" cellpadding="4" cellspacing="0" style="border-collapse: collapse">
<tr>
<td style="height: 186px">
<table border="0" cellpadding="0">
<tr>
<td align="center" style="font-weight: bold; font-size: 0.9em; color: white; height: 28px;
background-color: #008f00">
后 台 登 录</td>
</tr>
<tr>
<td>
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">用户名:</asp:Label></td>
</tr>
<tr>
<td>
<asp:TextBox ID="UserName" runat="server" Font-Size="0.8em"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
ErrorMessage="必须填写“用户名”。" ToolTip="必须填写“用户名”。" ValidationGroup="Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">密码:</asp:Label></td>
</tr>
<tr>
<td>
<asp:TextBox ID="Password" runat="server" Font-Size="0.8em" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
ErrorMessage="必须填写“密码”。" ToolTip="必须填写“密码”。" ValidationGroup="Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="RememberMe" runat="server" Text="下次记住我。" />
</td>
</tr>
<tr>
<td align="center" style="color: red">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
<tr>
<td align="right">
<asp:Button ID="LoginButton" runat="server" BackColor="Transparent" BorderColor="Green"
BorderStyle="Solid" BorderWidth="1px" CommandName="Login" Font-Names="Verdana"
Font-Size="0.8em" ForeColor="Green" Height="26px" OnClick="LoginButton_Click"
Text="登 录" ValidationGroup="Login1" Width="82px" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>现在我想通过他们实现登录功能,我所写的.aspx.cs的代码是
protected void LoginButton_Click(object sender, EventArgs e)
{
string user_name = Request.Params["UserName"];
string user_pwd = Request.Params["Password"];
Response.Write(user_name);
Response.Write(user_pwd);
}我发现获取不到这些相关的值,请问正确的写法是?谢谢
解决方案 »
- 关于c# 向sql server insert 数据问题的,在线等,急!!!!!!!!!!!!!!!!!
- 【Winform】自定义了一个单选按钮控件,问如何实现该控件间的互斥以实现单选效果?
- 问一个比较弱的问题,关于picturebox里的paint事件和onpaint
- .net页面中变量的生命周期问题
- c# WinForm 中 treeview实现整行选择
- Access查询速度DataReader 与DataSet的问题
- 高手请进:关于打印分页
- C#到底是语言还是开发工具??
- C#中 Repeater 数据列表中权限问题
- 一个关于datagrid的问题!
- .net 调用存储过程问题
- ISAM 错误(找不到可安装的)
UserName这个ID能直接找到么?
string user_name = Login1.UserName;
string password = Login1.Password;
{
string name = ((System.Web.UI.WebControls.Login)sender).UserName;
string psw = ((System.Web.UI.WebControls.Login)sender).Password;
}