对自己的看法

  个人学习ASP。NET也学了2个多月,才掌握了一些最基本的语法。对深奥的技术需要与大家一起探讨。从今天开始坚持每天写技术文章。与生活感想。嘿嘿。

  1.写一个用户的看法。要求是用户名不能为空;电子邮箱地址中必须有@符号;内容可以支持回车换行、也可以输入HTML代码、单引号、双引号、空格、&符号等等。

静态部分:

<table style="width: 569px; height: 367px;">
            <tr>
                <td style="width: 121px; text-align: left">
                    主题:</td>
                <td style="text-align: left">
                    <asp:TextBox ID="txtMotif" runat="server" Width="245px"></asp:TextBox></td>
                <td style="width: 4px">
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtMotif" ErrorMessage="必须输入主题" Width="188px"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
                <td style="width: 121px; text-align: left">
                    内容:</td>
                <td style="text-align: left">
                    <asp:TextBox ID="txtText" runat="server" Height="120px" TextMode="MultiLine" Width="245px"></asp:TextBox></td>
                <td style="width: 4px">
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtText" Width="190px">必须输入内容。</asp:RequiredFieldValidator></td>
            </tr>
            <tr>
                <td style="width: 121px; text-align: left">
                    姓名:</td>
                <td style="text-align: left">
                    <asp:TextBox ID="txtUserName" runat="server" Width="243px"></asp:TextBox></td>
                <td style="width: 4px">
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="必须输入姓名" Width="188px" ControlToValidate="txtUserName"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
                <td style="width: 121px; height: 21px; text-align: left">
                    电子邮箱地址:</td>
                <td style="height: 21px; text-align: left">
                    <asp:TextBox ID="txtEmailAddress" runat="server" Width="243px"></asp:TextBox></td>
                <td style="width: 4px; height: 21px; text-align: center;">
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="请输入正确E-mail格式" ControlToValidate="txtEmailAddress" ValidationExpression="/w+([-+.']/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*" Width="186px"></asp:RegularExpressionValidator>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtEmailAddress"
                        ErrorMessage="E-mail不能为空" Width="187px"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
                <td colspan="3" style="height: 21px; text-align: right">
                    <asp:Button ID="btnConfirm" runat="server" Text="确定" OnClick="btnConfirm_Click" />
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<asp:Button ID="btnClear"
                        runat="server" Text="重新填写" />
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                </td>
            </tr>
            <tr>
                <td colspan="3" style="height: 24px; text-align: left">
                    <asp:Label ID="lblInformation" runat="server" Width="386px"></asp:Label></td>
            </tr>
        </table>

分别用了两种控件。RequiredFieldValidator和RegularExpressionValidator

但是在内容上还有一个html代码没有做出来。。。

正在努力中。。。相信自己会更加出色。。。

阅读更多
个人分类: asp.net学习之旅
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭