WAP之家:为您提供最全最新的WAP技术,CP.SP.3G等行业资讯。 WAP之家交流论坛全新开放 点击进入>>
WAP资讯 | 3G动态 | SP动态 | 运营商动态 | 内容商动态 | 制造商动态 | 论坛讨论>> 每次自动访问
WAP技术 | WAP源码 | 手机编程 | 手机源码 | 无线技术 | J2ME技术 | 手机软件 添加到收藏夹
IVR技术 | SP资料 | SMS MMS技术 | 商业方案 | IVR下载 | 书籍教程 | 工具软件 语言:繁體中文

WAP之家技术文章WAP教程网站教程ASP.NET Mobile RequiredFieldValidator Control

ASP.NET Mobile RequiredFieldValidator Control
作者:佚名  来源:本站整理  发布时间:2008-3-14 20:51:49

Example 1
案例1

The following example contains two forms in an .aspx file. The first form has a label with the text "Please enter a number from 1 through 100", an input box to input a number, a RangeValidator control that checks that the input value is a number from 1 through 100, a RequiredFieldValidator control that checks that the input field isn't empty, and a submit button. The second page is activated by the submit button on the first page, and displays a response. If the input value validates as an error, an error message is displayed:
下面的案例包含了 .aspx 文件中的两张表单。第一张表单包含一个名为“Please enter a number from 1 through 100” 的标签,一个输入框,一个用于确认输入值范围从数字1-100的RangeValidator 控件,以及一个提交按钮。第二张页面将被第一张页面中的提交按钮激活。如果输入值确认出现错误,那么将显示一段错误信息:

<%@ Page 
Inherits="System.Web.UI.MobileControls.MobilePage"%>
<%@ Register TagPrefix="Mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script runat="server">
sub page2(Sender as Object,E as EventArgs)
if Page.IsValid then
ActiveForm=f2
lbl2.Text="You entered number " & txt1.text
end if
end sub
</script>

<Mobile:Form id="f1" runat="server">

<Mobile:Label runat="server">
Please enter a number from 1 through 100
</Mobile:Label>
  <Mobile:TextBox id="txt1" runat="server"/>
  <Mobile:RangeValidator
ControlToValidate="txt1"
Type="Integer"
MaximumValue="100"
MinimumValue="1"

Text="Invalid number"
runat="server" />
  <Mobile:RequiredFieldValidator
ControlToValidate="txt1"
Text="A number is required"

runat="server" />
  <Mobile:Command runat="server"
OnClick="page2">Submit
</Mobile:Command>

</Mobile:Form>
<Mobile:Form id="f2" runat="server">
<Mobile:Label id="lbl2" runat="server" />

</Mobile:Form>

上一页  [1] [2] 

[] [返回上一页] [打 印]
文章评论

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码