这似乎只需要一两行代码?
这是我需要做的:
- 将数据验证添加到“联系我们”表单上的新电话字段。我们只接受以下格式的电话:995-999-9999
- 填写联系我们表格,以便您可以将其作为电子邮件提交。将所有测试电子邮件发送至 blah@boo.net。您可以使用您必须发送电子邮件的任何电子邮件帐户。
这需要编程 API,例如:
- System.Net.Mail
- 邮件消息
- 客户端
- 网络凭证
这似乎很容易,但我对它非常迷茫。当我运行它时,此页面也不会显示。这是页面代码:我希望我做对了,如果不正确,请见谅。我在尝试!
<%@ Page Title="Contact Us" Language="vb" AutoEventWireup="false" MasterPageFile="~/Main.Master" CodeBehind="ContactUs.aspx.vb" Inherits="Week10.ContactUs" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h1>Contact Us</h1>
<hr />
<table border="1">
<tr>
<td>From</td>
<td>
<asp:TextBox ID="txtFrom" runat="server" Width="400px"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvFrom" CssClass="ErrMSG" runat="server" ControlToValidate="txtFrom" ErrorMessage="*" ToolTip="From field is required"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Subject</td>
<td>
<asp:TextBox ID="txtSubject" runat="server" Width="400px"></asp:TextBox>
</td>
<td><asp:RequiredFieldValidator ID="rfvSubject" CssClass="ErrMSG" runat="server" ControlToValidate="txtSubject" ErrorMessage="*" ToolTip="Subject field is required"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Phone</td>
<td>
<asp:TextBox ID="txtPhone" runat="server" Width="100px"></asp:TextBox>
</td>
<td><asp:RequiredFieldValidator ID="rfvPhone" CssClass="ErrMSG" runat="server" ControlToValidate="txtPhone" ErrorMessage="*" ToolTip="Phone field is required"></asp:RequiredFieldValidator>
</td>
</tr>
<tr valign="top">
<td>Comments</td>
<td>
<asp:TextBox ID="txtComments" runat="server" Rows="10" TextMode="MultiLine"
Width="400px"></asp:TextBox>
</td>
<td><asp:RequiredFieldValidator ID="rfvComments" CssClass="ErrMSG" runat="server" ControlToValidate="txtComments" ErrorMessage="*" ToolTip="Comments field is required"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td colspan="3" align="center">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" /></td>
</tr>
<tr>
<td colspan="3" align="center">
<asp:Label ID="lblMSG" runat="server" Text=""></asp:Label>
</td>
</tr>
</table>
</asp:Content>