ASP NET 登录界面

               

//default.aspx.csusing System;   using System.Collections.Generic;   using System.ComponentModel;   using System.Data;   using System.Drawing;   using System.Linq;   using System.Text;   using System.Data.OleDb;   using System.Data.SqlClient;   using System.Runtime.InteropServices;   using System.Configuration;   using System.Web.UI.WebControls;   using System.Web.Services.Description;  public partial class _Default : System.Web.UI.Page {    protected void Page_Load(object sender, EventArgs e)    {        Button4.Attributes.Add("onclick", "window.open('Register.aspx')");//通过button4打开链接        string strConnection = ConfigurationManager.AppSettings["Str.Properties.Settings.masterConnectionString"].ToString();        SqlConnection objConnection = new SqlConnection(strConnection);        objConnection.Open();        SqlCommand cmd = new SqlCommand("select * from judging where name='" + TextBox1.Text.Trim() + "'", objConnection);        string sql = "select * from judging where name='" + TextBox1.Text + "'and password='" + TextBox2.Text + "'";        cmd.CommandText = sql;        /*           ***********************************************************************************************           *判断是否有此ID,ExecuteScalar() return the first column of the first row in the result set.           */        if (cmd.ExecuteScalar() == null)//无此用户           {            Label1.Text = "Sorry, please check your id and psw";            Button3.Visible = false;        }        else        {            Label1.Text ="Welcome to "+TextBox1.Text;            Button3.Visible = true;        }           }    protected void Button1_Click(object sender, EventArgs e)    {                Panel1.Visible = false;        Panel2.Visible = true;    }    protected void Button4_Click(object sender, EventArgs e)    {            }    protected void Button3_Click(object sender, EventArgs e)    {    }    protected void LinkButton1_Click(object sender, EventArgs e)    {    }} 

 

 //default.aspx<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><!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 runat="server">    <title></title>    <link rel="Stylesheet" href="mystyle.css" mce_href="mystyle.css" type="text/css" /></head><body>    <form id="form1" runat="server">    <div class="tt">             <div class="menu">                 Online Judge</div>             <div class="menu">             </div>             <div class="menu">             </div>             <div class="menu" align="center">                 <asp:Panel ID="Panel1" runat="server" Height="127px">                     Login<br />                 <br />                 username<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>                 <br />                 password<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>                 <br />                 <br />                 <asp:Button ID="Button1" runat="server" οnclick="Button1_Click" Text="submit" />                                             <asp:Button ID="Button4" runat="server" Text="Register" />                 </asp:Panel>                                  <asp:Panel ID="Panel2" runat="server" Visible="False">                      <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>                                            <br />                      <asp:Button ID="Button3" runat="server" οnclick="Button3_Click" Text="修改密码" />                      <br />                      <br />                      <input type="button" οnclick="window.location='Register.aspx'" value="注册新用户" />                 </asp:Panel>             </div>        </div>    </form></body></html>

 

body {}.menu{ margin:10px; padding:10px; font-size:14px; display:block; float:left;    background-image:url(pic/bglogin.png);    background-position:center;    background-repeat:repeat-x;    border-style:solid;    border-width:3px;    width:20%;    height:90%;    }.menu ul{ background-color:#41428b; color:White; width:100%;}.tt{ height:150px;}

 

//Register.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Register.aspx.cs" Inherits="Register" %><!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 runat="server">    <title></title></head><body>    <form id="form1" runat="server">    <div align="center">            <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" BackColor="#F7F6F3"             BorderColor="#E6E2D8" BorderStyle="Solid" BorderWidth="1px"             Font-Names="Verdana" Font-Size="0.8em" Height="267px"             oncreateduser="CreateUserWizard1_CreatedUser" Width="318px">            <SideBarStyle BackColor="#5D7B9D" BorderWidth="0px" Font-Size="0.9em"                 VerticalAlign="Top" />            <SideBarButtonStyle BorderWidth="0px" Font-Names="Verdana" ForeColor="White" />            <ContinueButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC"                 BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"                 ForeColor="#284775" />            <NavigationButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC"                 BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"                 ForeColor="#284775" />            <HeaderStyle BackColor="#5D7B9D" BorderStyle="Solid" Font-Bold="True"                 Font-Size="0.9em" ForeColor="White" HorizontalAlign="Center" />            <CreateUserButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC"                 BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"                 ForeColor="#284775" />            <TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />            <StepStyle BorderWidth="0px" />            <WizardSteps>                <asp:CreateUserWizardStep runat="server">                    <ContentTemplate>                        <table border="0"                             style="font-family:Verdana;font-size:100%;height:267px;width:318px;">                            <tr>                                <td align="center" colspan="2"                                     style="color:White;background-color:#5D7B9D;font-weight:bold;" mce_style="color:White;background-color:#5D7B9D;font-weight:bold;">                                    注册新帐户</td>                            </tr>                            <tr>                                <td align="right">                                    <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">用户名:</asp:Label>                                </td>                                <td>                                    <asp:TextBox ID="UserName" runat="server"></asp:TextBox>                                    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server"                                         ControlToValidate="UserName" ErrorMessage="必须填写“用户名”。" ToolTip="必须填写“用户名”。"                                         ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>                                </td>                            </tr>                            <tr>                                <td align="right">                                    <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">密码:</asp:Label>                                </td>                                <td>                                    <asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>                                    <asp:RequiredFieldValidator ID="PasswordRequired" runat="server"                                         ControlToValidate="Password" ErrorMessage="必须填写“密码”。" ToolTip="必须填写“密码”。"                                         ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>                                </td>                            </tr>                            <tr>                                <td align="right">                                    <asp:Label ID="ConfirmPasswordLabel" runat="server"                                         AssociatedControlID="ConfirmPassword">确认密码:</asp:Label>                                </td>                                <td>                                    <asp:TextBox ID="ConfirmPassword" runat="server"                                         ontextchanged="ConfirmPassword_TextChanged" TextMode="Password"></asp:TextBox>                                    <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server"                                         ControlToValidate="ConfirmPassword" ErrorMessage="必须填写“确认密码”。"                                         ToolTip="必须填写“确认密码”。" ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>                                </td>                            </tr>                            <tr>                                <td align="right">                                    <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">电子邮件:</asp:Label>                                </td>                                <td>                                    <asp:TextBox ID="Email" runat="server"></asp:TextBox>                                    <asp:RequiredFieldValidator ID="EmailRequired" runat="server"                                         ControlToValidate="Email" ErrorMessage="必须填写“电子邮件”。" ToolTip="必须填写“电子邮件”。"                                         ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>                                </td>                            </tr>                            <tr>                                <td align="right">                                    <asp:Label ID="QuestionLabel" runat="server" AssociatedControlID="Question">安全提示问题:</asp:Label>                                </td>                                <td>                                    <asp:TextBox ID="Question" runat="server"></asp:TextBox>                                    <asp:RequiredFieldValidator ID="QuestionRequired" runat="server"                                         ControlToValidate="Question" ErrorMessage="必须填写“安全提示问题”。"                                         ToolTip="必须填写“安全提示问题”。" ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>                                </td>                            </tr>                            <tr>                                <td align="right">                                    <asp:Label ID="AnswerLabel" runat="server" AssociatedControlID="Answer">安全答案:</asp:Label>                                </td>                                <td>                                    <asp:TextBox ID="Answer" runat="server"></asp:TextBox>                                    <asp:RequiredFieldValidator ID="AnswerRequired" runat="server"                                         ControlToValidate="Answer" ErrorMessage="必须填写“安全答案”。" ToolTip="必须填写“安全答案”。"                                         ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>                                </td>                            </tr>                            <tr>                                <td align="center" colspan="2">                                    <asp:CompareValidator ID="PasswordCompare" runat="server"                                         ControlToCompare="Password" ControlToValidate="ConfirmPassword"                                         Display="Dynamic" ErrorMessage="“密码”和“确认密码”必须匹配。"                                         ValidationGroup="CreateUserWizard1"></asp:CompareValidator>                                </td>                            </tr>                            <tr>                                <td align="center" colspan="2" style="color:Red;" mce_style="color:Red;">                                    <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>                                </td>                            </tr>                        </table>                    </ContentTemplate>                </asp:CreateUserWizardStep>                <asp:CompleteWizardStep runat="server" />            </WizardSteps>        </asp:CreateUserWizard>        </div>    </form></body></html>

 

 //Register.aspx.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Data.OleDb;using System.Data.SqlClient;using System.Runtime.InteropServices;using System.Configuration;using System.Web.UI.WebControls;using System.Web.Services.Description;  public partial class Register : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {    }    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)    {        String user = CreateUserWizard1.UserName.ToString();        String psw = CreateUserWizard1.Password.ToString();        String psw2 = CreateUserWizard1.ConfirmPassword.ToString();        string strConnection = ConfigurationManager.AppSettings["Str.Properties.Settings.masterConnectionString"].ToString();        SqlConnection objConnection = new SqlConnection(strConnection);        objConnection.Open();        SqlCommand cmd = new SqlCommand("select * from judging where name='" + user + "'", objConnection);        /*           ***********************************************************************************************           *判断是否有此ID,ExecuteScalar() return the first column of the first row in the result set.           */        if (cmd.ExecuteScalar() == null)//无此用户           {            Response.Write("OK");            string user1 = CreateUserWizard1.UserName.ToString();            string psw1 = CreateUserWizard1.Password.ToString();            string sql = "insert into judging (userid,name,password) values('" + 50 + "','" + user1 + "','" + psw1 + "')";            cmd.CommandText = sql;            cmd.ExecuteNonQuery();        }        else        {            Response.Write("已创建此用户,please try another username");        }    }    protected void ConfirmPassword_TextChanged(object sender, EventArgs e)    {    }}

 

           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
asp.net是一种非常强大且功能丰富的开发框架,可以用于构建漂亮的登录界面。在创建漂亮的登录界面时,我们可以使用asp.net提供的丰富的控件和样式来实现。 首先,我们可以使用asp.net提供的Login控件,该控件具有一些内置的属性和事件,可以轻松地在网站中添加登录功能。我们可以使用控件的样式属性来定制登录表单的外观,例如背景色、字体大小和颜色等。同时,我们还可以自定义控件的模板,以实现更灵活和个性化的登录界面。 其次,在设计登录界面时,我们可以使用一些现代化的设计技术来增加页面的美观性和用户体验。例如,可以使用CSS3来添加过渡效果、阴影和动画效果,使登录界面看起来更加生动和吸引人。此外,还可以使用响应式设计,使登录界面在不同设备上都能够自适应,并保持良好的显示效果。 另外,我们还可以添加一些额外的元素来增加登录界面的吸引力。例如,可以添加公司或品牌的logo,以增加页面的专业感和可信度。另外,可以添加背景图片或渐变色,以提供更加吸引人的视觉效果。此外,还可以添加输入框的提示信息或说明,以帮助用户更好地理解登录流程。 总之,asp.net提供了很多强大的工具和技术来创建漂亮的登录界面。我们可以使用其丰富的控件和样式来实现个性化设计,并结合现代化的设计技术来增加页面的美观性和用户体验。通过使用asp.net的这些功能,我们可以轻松地打造一个令人印象深刻和漂亮的登录界面
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值