电脑技术学习

DreamwaverMX与ASP.NET(十四)

dn001
RangeValidator控件


[图5-12 RangeValidatorr设置对话框]

可以通过Mininum Value(最小值),Maxinum Value(最大值)来设置值的范围。同时可以通过Type来设置比较的类型,例如”string”,”Integer”等。其他设置类似于其他组件的设置。

还有一个组件:ValidationSummary。其中HeaderText设置抬头文字,DisplayMode设置显示模式,其具体属性如下:

属性值

意义

List

BulletList

SingleParagraph

ErrorMessage分行显示

ErrorMessage分项显示

ErrorMessage显示成同一行



[图5-13 ValidationSummary属性设置对话框]

代附上主要程序段的源代码:

< table width="75%" height="594" border="1" cellpadding="1" cellspacing="0" bordercolor="#999999" >

< tr >

< td width="22%" height="22" >First Name< /td >

< td width="38%" >< asp:textbox BackColor="#CCCCCC" ForeColor="#0033FF" ID="first" runat="server" TextMode="SingleLine" ToolTip="Please input the first name" MaxLength="40" BorderWidth="1" width="200"/ >< /td >

< td width="40%" >< asp:requiredfIEldvalidator BackColor="#CCCCCC" ControlToValidate="first" ErrorMessage="RequiredField" ForeColor="#FF0000" ID="validname" runat="server" / > < /td >

< /tr >

< tr >

< td height="22" >Last Name< /td >

< td >< asp:textbox BackColor="#CCCCCC" ForeColor="#0033FF" ID="Lastname" runat="server" TextMode="SingleLine" Width="200" ToolTip="Please input the last name" BorderWidth="1"/ >< /td >

< td >< asp:requiredfieldvalidator BackColor="#CCCCCC" ControlToValidate="Lastname" ErrorMessage="RequiredField" ForeColor="#FF0000" ID="vailLast" runat="server" / > < /td >

< /tr >

< tr >

< td height="22" >Telephone< /td >

< td >< asp:textbox BackColor="#CCCCCC" BorderWidth="1" ForeColor="#0066FF" ID="telephone" runat="server" TextMode="SingleLine" ToolTip="Please input your telephone" Width="200" / >< /td >

< td > < asp:regularexpressionvalidator BackColor="#CCCCCC" ControlToValidate="telephone" ErrorMessage="7-10 numbers required" ForeColor="#FF0000" ID="vailtel" runat="server" ValidationExpression="[0-9]{7,10}" / > < asp:requiredfieldvalidator BackColor="#CCCCCC" ControlToValidate="telephone" ErrorMessage="RequiredField" ForeColor="#FF0000" ID="vailtel2" runat="server" / >< /td >

< /tr >

< tr >

< td height="22" >Email< /td >

< td >< asp:textbox BackColor="#CCCCCC" BorderWidth="1" ForeColor="#0033FF" ID="email" runat="server" TextMode="SingleLine" ToolTip="Please input your E-mail" width="200"/ >< /td >

< td >< asp:regularexpressionvalidator BackColor="#CCCCCC" ControlToValidate="email" ErrorMessage="Invaliate Email address" ForeColor="#FF0000" ID="valiemail" runat="server" ValidationExpression=".{1,}@.{3,}" / > < asp:requiredfieldvalidator BackColor="#CCCCCC" ControlToValidate="email" ErrorMessage="Required Field" ForeColor="#FF0000" ID="valiemail2" runat="server" / > < /td >

< /tr >

< tr >

< td height="22" colspan="3" >< div align="center" >Comments< /div >< /td >

< /tr >

< tr >

< td height="188" colspan="3" >< div align="center" >

< asp:textbox BackColor="#CCCCCC" BorderWidth="1" ForeColor="#0033FF" ID="Comments" Rows="16" runat="server" TextMode="MultiLine" ToolTip="Please input the Comments" width="400"/ >

< /div >

< div align="center" > < br >

< /div >< /td >

< /tr >

< tr >

< td height="71" colspan="3" >< div align="center" >

< asp:validationsummary BackColor="#CCCCCC" DisplayMode="BulletList" ForeColor="#FF0000" HeaderText="有误的内容包括:" ID="valSum" runat="server" ToolTip="Error" / >

< /div >< /td >

< /tr >

< tr >

< td height="22" colspan="3" >< input type="submit" name="Submit" value="Submit" >

< /td >

< /tr >

< /table >

样式如下:


[图5-14 预览]