简单教程
提交运行
代码编辑器:
<script runat="server"> Sub submit(sender As Object, e As EventArgs) If Page.IsValid Then lbl1.Text="Page is valid." Else lbl1.Text="Page is not valid!!" End If End Sub </script> <!DOCTYPE html> <meta charset="utf-8" /> <form runat="server"> Enter a number from 1 to 100: <asp:TextBox id="tbox1" runat="server" /> <br><br> <asp:Button Text="Submit" OnClick="submit" runat="server" /> <br><br> <asp:Label id="lbl1" runat="server" /> <br> <asp:RangeValidator ControlToValidate="tbox1" MinimumValue="1" MaximumValue="100" Type="Integer" EnableClientScript="false" Text="The value must be from 1 to 100!" runat="server" /> </form>
运行结果: