ASP.Net/Mobile Control/Range Validator

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Mobile range validator for date (VB.net)

<%@ Page 
    Inherits="System.Web.UI.MobileControls.MobilePage" 
    Language="VB" 
%>
<%@ Register 
    TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" 
%>
<script runat="server" language="VB">
Sub OK_OnSubmit(Sender As Object, E As EventArgs)
    If Page.IsValid Then
        ActiveForm = FinishForm
        lbl2.Text = "You entered " & txtNumber.Text _
            & " and " & txtDate.Text
    Else
        ActiveFOrm = ErrorForm
    End If
End Sub
</script>
<mobile:form 
    id="StartForm" 
    runat="server">
    <mobile:label 
        runat="server" 
        id="lbl1"
        Text="Enter a number from 1 to 5:" 
    />
    <mobile:textbox
        runat="server" 
        id="txtNumber"
    />
    <mobile:rangevalidator 
        id="rngNumber" 
        controltovalidate="txtNumber" 
        type="Integer" 
        minimumvalue=1
        maximumvalue=5
        runat="server"
        errormessage="Number not in correct range!!!"
    />
    <mobile:label 
        runat="server" 
        id="lbl1b"
        Text="Enter a date in 2005:" 
    />
    <mobile:textbox
        runat="server" 
        id="txtDate"
    />
    <mobile:rangevalidator 
        id="rngDate" 
        controltovalidate="txtDate" 
        type="Date" 
        minimumvalue="1/1/2005"
        maximumvalue="12/31/2005"
        runat="server"
        errormessage="Date not in correct range!!!"
    />
    <mobile:Command 
        runat="server" 
        id="cmdOK"
        OnClick="OK_OnSubmit" 
        Text="OK" 
    />
</mobile:form>
<mobile:form 
    id="FinishForm" 
    runat="server">
    <mobile:label 
        runat="server" 
        id="lbl2"
    />
</mobile:form>
<mobile:form 
    id="ErrorForm" 
    runat="server">
    <mobile:validationsummary 
        id="vsAllErrors" 
        runat="server"
        headertext="For these reasons, 
            your data could not be processed:"
        formtovalidate="StartForm"
    />    
</mobile:form>



Mobile range validator (VB.net)

<%@ Page 
    Inherits="System.Web.UI.MobileControls.MobilePage" 
    Language="VB" 
%>
<%@ Register 
    TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" 
%>
<script runat="server" language="VB">
Sub OK_OnSubmit(Sender As Object, E As EventArgs)
    If Page.IsValid Then
        ActiveForm = FinishForm
        lbl2.Text = "You entered " & txtNumber.Text _
            & " and " & txtDate.Text
    End If
End Sub
</script>
<mobile:form 
    id="StartForm" 
    runat="server">
    <mobile:label 
        runat="server" 
        id="lbl1"
        Text="Enter a number from 1 to 5:" 
    />
    <mobile:textbox
        runat="server" 
        id="txtNumber"
    />
    <mobile:rangevalidator 
        id="rngNumber" 
        controltovalidate="txtNumber" 
        type="Integer" 
        minimumvalue=1
        maximumvalue=5
        runat="server"
        errormessage="Number not in correct range!!!"
    />
    <mobile:label 
        runat="server" 
        id="lbl1b"
        Text="Enter a date in 2005:" 
    />
    <mobile:textbox
        runat="server" 
        id="txtDate"
    />
    <mobile:rangevalidator 
        id="rngDate" 
        controltovalidate="txtDate" 
        type="Date" 
        minimumvalue="1/1/2005"
        maximumvalue="12/31/2005"
        runat="server"
        errormessage="Date not in correct range!!!"
    />
    <mobile:Command 
        runat="server" 
        id="cmdOK"
        OnClick="OK_OnSubmit" 
        Text="OK" 
    />
</mobile:form>
<mobile:form 
    id="FinishForm" 
    runat="server">
    <mobile:label 
        runat="server" 
        id="lbl2"
    />
</mobile:form>