asp.net 验证表单 服务器控件
我希望点击提交后,所填写的信息,在下面显示出来。但是这代码,不行么。提交后没什么反映<% @ Page Language="VB" Debug="true"%>
<% @ Import Namespace="System.IO" %>
<script Language="VB" runat="server">
Sub Enter_Click(Sender As Object, E As EventArgs)
If Page.IsValid=True Then
Dim strMessage,filename,filepath As String
strMessage="用户名:" & user_name.Text
strMessage=strMessage & "<br>姓名:" & real_name.Text '获取姓名
strMessage=strMessage & "<br>密码:" & password1.Text '获取密码
strMessage=strMessage & "<br>确认密码: " & password2.Text
strMessage=strMessage & "<br>性别:" & 易做图.SelectedItem.Text '获取性别
strMessage=strMessage & "<br>出生日期:" &day.Text
strMessage=strMessage & "<br>邮箱:" &email.Text
strMessage=strMessage & "<br>电话:" &tele.Text
'下面的循环用来获取爱好,比较复杂。
strMessage=strMessage & "<br>爱好:"
Dim I As Integer
For I = 0 to love.Items.Count-1 '依次判断所有的项
If love.Items(I).Selected=True Then
strMessage = strMessage & love.Items(I).Text & ","
End If
Next
strMessage=strMessage & "<br>简介:" & introduction.Text '获取简介
filename= Path.GetFileName(uploadfile.PostedFile.FileName)
filepath= "C:\Inetpub\wwwroot\aspstudy\examples\aspx\upload\" & filename
uploadfile.PostedFile.SaveAs(filepath)
message1.InnerHtml = "头像已经成功上载,详细信息如下"
message1.InnerHtml &= "<br><img src='upload\"& filename &"' height=100px width=100px>"
message.Text=strMessage
End If
End sub
</script>
<html>
<body>
<h4 align="center">请填写个人信息</h4>
<form runat="server">
用户名:<asp:Textbox id="user_name" runat="server"/>
<asp:RequiredFieldValidator id="require1" ControlToValidate="user_name" ErrorMessage="必须输入用户名" runat="server"/>
<asp:RegularExpressionValidator id="Regular1" ControlToValidate="user_name" ValidationExpression="[a-zA-Z][a-zA-Z0-9_]{0,}" ErrorMessage="第一个字符必须为字母,且只能包含字母,数字和下划线" runat="server"/><br>
姓名:<asp:Textbox id="real_name" runat="server"/><br>
密码: <asp:Textbox id="password1" Textmode="Password" runat="server"/><br>
确认密码:<asp:Textbox id="password2" Textmode="Password" runat="server"/>
<asp:RequiredFieldValidator id="require2" ControlToValidate="password1" ErrorMessage="必须输入密码" runat="server"/>
<asp:CompareValidator id="Compare1" ControlToValidate="password1" ControlToCompare="password2" ErrorMessage="密码和确认密码必须一致" runat="server"/>
<br>
性别:
<asp:RadioButtonList id="易做图" RepeatDirection="Horizontal" runat="server">
<asp:Listitem value="male">男</asp:Listitem>
<asp:Listitem value="female">女</asp:Listitem>
</asp:RadioButtonList>
出生日期:<asp:Textbox id="day" runat="server"/><br>
邮箱:<asp:Textbox id="email" runat="server"/>
<asp:RequiredFieldValidator id="require3" ControlToValidate="email" ErrorMessage="必须输入邮箱地址" runat="server"/>
<asp:RegularExpressionValidator id="Regular2" ControlToValidate="email" ValidationExpression=".{1,}@.{1,}\.[a-zA-Z]{2,3}" ErrorMessage="必须输入正确的E-mail地址" runat="server"/><br>
电话:<asp:Textbox id="tele" runat="server"/>
<asp:RequiredFieldValidator id="require4" ControlToValidate="tele" ErrorMessage="必须输入电话" runat="server"/>
<asp:RegularExpressionValidator id="Regular3" ControlToValidate="tele" ValidationExpression="[0-9]{3,4}-[0-9]{7,8}" ErrorMessage="必须输入正确电话,如:101-78787878或0571-12121212" runat="server"/><br>
爱好:
<asp:CheckBoxList id="love" RepeatDirection="Horizontal" runat="server">
<asp:Listitem value="music" >音乐</asp:Listitem>
<asp:Listitem value="computer" >计算机</asp:Listitem>
<asp:Listitem value="game" >打游戏</asp:Listitem>
</asp:CheckBoxList >
简介:<asp:Textbox id="introduction" Textmode="Multiline" rows="3" columns="40" runat="server"/><br>
上传头像:<input id="uploadfile" type="file" runat="server">
<br><asp:button style="width:60px;height:30px;FONT-SIZE:9pt" Text="提交" onClick="Enter_click" runat="server"/>
<br><asp:label id="message" Text="显示输入内容" runat="server"/>
<p><span id="message1" runat="server" />
</form>
</body>
</html> --------------------编程问答-------------------- 在线等啊,,,找不出错误啊!! --------------------编程问答-------------------- jquery 验证
补充:.NET技术 , ASP.NET