User input date Validating

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tamer Ibrahim

    User input date Validating

    Hi,

    I'm trying to validate user input date using range validator on a text box .
    This code is throwing this exception

    "The value 'DateTime.Now;' of the MaximumValue property of 'rvQDate' cannot
    be converted to type 'Date'. "

    <asp:TextBox ID="txtQDate" runat="server" Enabled="False" ></asp:TextBox>

    <asp:Image ID="iQDate" runat="server" ImageUrl="~/images/Calendar.png"
    Visible="False" />

    <cc1:CalendarEx tender ID="calQDate" runat="server" BehaviorID="cal QDate"
    TargetControlID ="txtQDate" PopupButtonID=" iQDate" Format="dd/MM/yyyy">

    </cc1:CalendarExt ender>

    <asp:RangeValid ator ID="rvQDate" runat="server" ControlToValida te="txtQDate"
    Display="Dynami c"

    ErrorMessage="I nvalid QDate." MaximumValue="D ateTime.Now;" Type="Date"
    CultureInvarian tValues="True"> *</asp:RangeValida tor>

    How can I solve this ?


  • Riki

    #2
    Re: User input date Validating

    Tamer Ibrahim wrote:
    Hi,
    >
    I'm trying to validate user input date using range validator on a
    text box . This code is throwing this exception
    >
    "The value 'DateTime.Now;' of the MaximumValue property of 'rvQDate'
    cannot be converted to type 'Date'. "
    >
    <asp:TextBox ID="txtQDate" runat="server"
    Enabled="False" ></asp:TextBox>
    <asp:Image ID="iQDate" runat="server" ImageUrl="~/images/Calendar.png"
    Visible="False" />
    >
    <cc1:CalendarEx tender ID="calQDate" runat="server"
    BehaviorID="cal QDate" TargetControlID ="txtQDate"
    PopupButtonID=" iQDate" Format="dd/MM/yyyy">
    </cc1:CalendarExt ender>
    >
    <asp:RangeValid ator ID="rvQDate" runat="server"
    ControlToValida te="txtQDate" Display="Dynami c"
    >
    ErrorMessage="I nvalid QDate." MaximumValue="D ateTime.Now;" Type="Date"
    CultureInvarian tValues="True"> *</asp:RangeValida tor>
    >
    How can I solve this ?
    You can not set the MaximumValue="D ateTime.Now" like that (declaratively) .
    This will cause the value to be set to the literal string value, which
    throws an error.

    You can set it programmaticall y, though.
    Leave the MaximumValue empty, and add this line to the Page_Load event:
    rvQDate.Maximum Value=DateTime. Now

    --

    Riki


    Comment

    Working...