ASP.Net/Mobile Control/Date Validation

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

Mobile validation control for date input (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 cvCheckDate.IsValid Then
        ActiveForm = FinishForm
        lbl2.Text = "You entered " & txtDate.Text
    End If
End Sub
</script>
<mobile:form 
    id="StartForm" 
    runat="server">
    <mobile:label 
        runat="server" 
        id="lbl1"
        Text="Please enter a date:" 
    />
    <mobile:textbox
        runat="server" 
        id="txtDate"
    />
    <mobile:comparevalidator 
        id="cvCheckDate" 
        controltovalidate="txtDate"
        operator="DataTypeCheck" 
        type="Date" 
        errormessage="You must enter a date!!!"
        runat="server"
    />
    <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>