1. 程式人生 > >c#web窗體登入介面登入註冊以及密碼找回傳送郵箱功能

c#web窗體登入介面登入註冊以及密碼找回傳送郵箱功能

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="register.aspx.cs" Inherits="ebook.Pages.register" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title></title>
    <style type="text/css">
        .auto-style1 {
            width: 600px;
        }

        #table2 tr td:first-child {
            width: 100px;
            text-align: right;
        }

        #table2 tr td:last-child {
            text-align: left;
        }

        #table2 th {
            width: 220px;
            text-align: left;
        }

        .auto-style2 {
            height: 23px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <table align="center" class="auto-style1">
            <tr>
                <td style="text-align: center">
                    <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="楷體" Font-Size="XX-Large" ForeColor="#3366FF" Text="使用者註冊"></asp:Label>
                </td>
            </tr>
            <tr>
                <td> </td>
            </tr>
            <tr>
                <td>
                    <table class="auto-style1" id="table2">
                        <tr>
                            <td>
                                <asp:Label ID="Label2" runat="server" Text="使用者名稱:"></asp:Label>
                            </td>
                            <th>
                                <asp:TextBox ID="txt_User_Name" runat="server" TabIndex="1"></asp:TextBox>
                                *</th>
                            <td>
                                <asp:Button ID="btn_Check" runat="server" OnClick="btn_Check_Click" TabIndex="2" Text="檢測使用者名稱" />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txt_User_Name" ErrorMessage="RequiredFieldValidator" ForeColor="Red">此項必填</asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label3" runat="server" Text="密碼:"></asp:Label>
                            </td>
                            <th>
                                <asp:TextBox ID="txt_User_Pwd" runat="server" TabIndex="3"></asp:TextBox>
                                *</th>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txt_User_Pwd" ErrorMessage="RequiredFieldValidator" ForeColor="Red">此項必填</asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td class="auto-style2">
                                <asp:Label ID="Label4" runat="server" Text="確認密碼:"></asp:Label>
                            </td>
                            <th class="auto-style2">
                                <asp:TextBox ID="txt_ReUser_Pwd" runat="server" TabIndex="4"></asp:TextBox>
                                *</th>
                            <td class="auto-style2">
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txt_ReUser_Pwd" ErrorMessage="RequiredFieldValidator" ForeColor="Red">此項必填</asp:RequiredFieldValidator>
                                <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txt_User_Pwd" ControlToValidate="txt_ReUser_Pwd" ErrorMessage="CompareValidator">兩次輸入的密碼不一致</asp:CompareValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label5" runat="server" Text="姓名:"></asp:Label>
                            </td>
                            <th>
                                <asp:TextBox ID="txt_Rel_Name" runat="server" TabIndex="5"></asp:TextBox>
                                *</th>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txt_Rel_Name" ErrorMessage="RequiredFieldValidator" ForeColor="Red">此項必填</asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label6" runat="server" Text="性別:"></asp:Label>
                            </td>
                            <th>
                                <asp:DropDownList ID="DDL_Sex" runat="server" TabIndex="6">
                                    <asp:ListItem>男</asp:ListItem>
                                    <asp:ListItem>女</asp:ListItem>
                                </asp:DropDownList>
                            </th>
                            <td> </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label7" runat="server" Text="出生日期:"></asp:Label>
                            </td>
                            <th>
                                <asp:DropDownList ID="DDL_Year" runat="server" TabIndex="7">
                                </asp:DropDownList>年
                             
                                <asp:DropDownList ID="DDL_Month" runat="server" TabIndex="8">
                                </asp:DropDownList>月
                             
                                <asp:DropDownList ID="DDL_Day" runat="server" TabIndex="9">
                                </asp:DropDownList>日
                            </th>
                            <td> </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label8" runat="server" Text="聯絡地址:"></asp:Label>
                            </td>
                            <th>
                                <asp:TextBox ID="txt_Address" runat="server" TabIndex="10"></asp:TextBox>
                            </th>
                            <td> </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label9" runat="server" Text="郵政編碼:"></asp:Label>
                            </td>
                            <th>
                                <asp:TextBox ID="txt_Postalcode" runat="server" TabIndex="11"></asp:TextBox>
                            </th>
                            <td>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txt_Postalcode" ErrorMessage="RegularExpressionValidator" ValidationExpression="\d{6}">郵政編碼不符合</asp:RegularExpressionValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label10" runat="server" Text="聯絡電話:"></asp:Label>
                            </td>
                            <th>
                                <asp:TextBox ID="txt_Tel" runat="server" TabIndex="12"></asp:TextBox>
                                *</th>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txt_Tel" ErrorMessage="RequiredFieldValidator" ForeColor="Red">此項必填</asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txt_Tel" ErrorMessage="RegularExpressionValidator" ValidationExpression="^[1][358][0-9]{9}$">聯絡電話格式不符合</asp:RegularExpressionValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label11" runat="server" Text="手機:"></asp:Label>
                            </td>
                            <th>
                                <asp:TextBox ID="txt_Mobile" runat="server" TabIndex="13"></asp:TextBox>
                            </th>
                            <td> </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label14" runat="server" Text="郵箱:"></asp:Label>
                            </td>
                            <th>
                                <asp:TextBox ID="txt_mail" runat="server" TabIndex="15"></asp:TextBox>
                            </th>
                            <td class="auto-style2">
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="txt_mail" ErrorMessage="RequiredFieldValidator" ForeColor="Red">此項必填</asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ControlToValidate="txt_mail" ErrorMessage="RegularExpressionValidator" ValidationExpression="^[a-zA-Z0-9_-]
[email protected]
[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$">郵箱格式不符</asp:RegularExpressionValidator> </td> </tr> <tr> <td class="auto-style2"> <asp:Label ID="Label12" runat="server" Text="身份證號:"></asp:Label> </td> <th class="auto-style2"> <asp:TextBox ID="txt_ID_Card" runat="server" TabIndex="14"></asp:TextBox> *</th> <td class="auto-style2"> <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txt_ID_Card" ErrorMessage="RequiredFieldValidator" ForeColor="Red">此項必填</asp:RequiredFieldValidator> <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="txt_ID_Card" ErrorMessage="RegularExpressionValidator" ValidationExpression="\d{17}[\d|X]|\d{15}">身份證號碼格式不符</asp:RegularExpressionValidator> </td> </tr> <tr> <td> </td> <th> <asp:Button ID="btn_Register" runat="server" OnClick="btn_Register_Click" TabIndex="15" Text="註冊" /> <asp:Button ID="btn_Catch" runat="server" OnClick="btn_Catch_Click" TabIndex="16" Text="重填" /> <asp:Label ID="Label13" runat="server" Font-Size="Smaller" ForeColor="Red" Text="帶*的為必填項"></asp:Label> </th> <td> </td> </tr> </table> </td> </tr> <tr> <td style="text-align: center"> <asp:Label ID="Labinfo" runat="server" Font-Size="Smaller" ForeColor="Red"></asp:Label> </td> </tr> </table> </form> </body> </html>

4.註冊頁面aspx.cs程式碼