F
fancylxs
Unregistered / Unconfirmed
GUEST, unregistred user!
以下代码有错误:
错误提示:
“checktomail1”的 ControlToValidate 属性不能为空。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Web.HttpException: “checktomail1”的 ControlToValidate 属性不能为空。
<%@ import namespace="system.web.mail" %>
<script language="vb" runat="server">
sub sentbutton_click(sender as object,e as eventargs)
dim mymail as new mailmessage
mymail.from=frommail.text
mymail.to=tomail.text
mymail.subject=subject.text
mymail.body=mailbody.text
smtpmail.send(mymail)
mailpanel.visible=false
mylabel.text="已经将你的信件顺利寄出"
end sub
</script>
<html>
<head>
</head>
<body>
<asp:label id="mylabel" runat="server"/>
<aspanel id="mailpanel" runat="server">
<form runat="server">
<table><td width=100>寄件人</td>
<td><asp:textbox id="frommail" runat="server"/>
<asp:regularexpressionvalidator
id="checkfrommail1" runat="server"
controltovalidate="frommail"
validationexpression=".{1,}@.{3,}/..{1,}"
text="格式错误"/>
<asp:requiredfieldvalidator id="checkfrommail2" runat="server"
controltovalidate="frommail" errormessage="请填email"/>
</td></tr>
<tr><td width=100>收件人</td>
<td><asp:textbox id="tomail" runat="server"/>
<asp:regularexpressionvalidator
id="checktomail1" runat="server"
controltovalidator="tomail"
validationexpression=".{1,}@.{3,}/..{1,}"
text="格式错误"/>
<asp:requiredfieldvalidator id="checktomail2" runat="server"
controltovalidate="tomail" errormessage="请填email"/>
</td></tr>
<tr><td width=100>标题</td>
<td><asp:textbox id="subject" runat="server"/>
<asp:requiredfieldvalidator id="checksubject" runat="server"
controltovalidate="subject" errormessage="请填写标题"/>
</td></tr><tr>
<td width=100>信件内容</td>
<td><asp:textbox textmode="multiline" id="mailbody" runat="server"/>
<asp:requiredfieldvalidator id="checkmailbody" runat="server"
controltovalidate="mailbody" errormessage="请填写信件内容"/>
</td></tr></table>
<asp:button id="sentbutton" runat="server" text="传送信件"
onclick="sentbutton_click"/>
</table>
</form>
</aspanel>
</body>
</html>
错误提示:
“checktomail1”的 ControlToValidate 属性不能为空。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Web.HttpException: “checktomail1”的 ControlToValidate 属性不能为空。
<%@ import namespace="system.web.mail" %>
<script language="vb" runat="server">
sub sentbutton_click(sender as object,e as eventargs)
dim mymail as new mailmessage
mymail.from=frommail.text
mymail.to=tomail.text
mymail.subject=subject.text
mymail.body=mailbody.text
smtpmail.send(mymail)
mailpanel.visible=false
mylabel.text="已经将你的信件顺利寄出"
end sub
</script>
<html>
<head>
</head>
<body>
<asp:label id="mylabel" runat="server"/>
<aspanel id="mailpanel" runat="server">
<form runat="server">
<table><td width=100>寄件人</td>
<td><asp:textbox id="frommail" runat="server"/>
<asp:regularexpressionvalidator
id="checkfrommail1" runat="server"
controltovalidate="frommail"
validationexpression=".{1,}@.{3,}/..{1,}"
text="格式错误"/>
<asp:requiredfieldvalidator id="checkfrommail2" runat="server"
controltovalidate="frommail" errormessage="请填email"/>
</td></tr>
<tr><td width=100>收件人</td>
<td><asp:textbox id="tomail" runat="server"/>
<asp:regularexpressionvalidator
id="checktomail1" runat="server"
controltovalidator="tomail"
validationexpression=".{1,}@.{3,}/..{1,}"
text="格式错误"/>
<asp:requiredfieldvalidator id="checktomail2" runat="server"
controltovalidate="tomail" errormessage="请填email"/>
</td></tr>
<tr><td width=100>标题</td>
<td><asp:textbox id="subject" runat="server"/>
<asp:requiredfieldvalidator id="checksubject" runat="server"
controltovalidate="subject" errormessage="请填写标题"/>
</td></tr><tr>
<td width=100>信件内容</td>
<td><asp:textbox textmode="multiline" id="mailbody" runat="server"/>
<asp:requiredfieldvalidator id="checkmailbody" runat="server"
controltovalidate="mailbody" errormessage="请填写信件内容"/>
</td></tr></table>
<asp:button id="sentbutton" runat="server" text="传送信件"
onclick="sentbutton_click"/>
</table>
</form>
</aspanel>
</body>
</html>