Require entry for Calendar control

Discussion in 'ASP .Net Web Controls' started by David Thielen, May 28, 2006.

  1. Hi;

    I have:
    <asp:Calendar ID="mapCalendarValue" runat="server"
    Visible="false"></asp:Calendar>
    <asp:RequiredFieldValidator ID="mapCalValidator" runat="server"
    ErrorMessage="RequiredFieldValidator"
    ControlToValidate="mapCalendarValue"></asp:RequiredFieldValidator>

    which gives me:
    [HttpException (0x80004005): Control 'mapCalendarValue' referenced by the
    ControlToValidate property of 'mapCalValidator' cannot be validated.]

    How can I require a selected date in the calendar control?

    --
    thanks - dave
    david_at_windward_dot_net
    http://www.windwardreports.com
     
    David Thielen, May 28, 2006
    #1
    1. Advertising

  2. ps - I know that this control defaults to 1/1/1 - I want a validator that
    requires a selection other than the default - and if the default changes,
    knows that too.

    --
    thanks - dave
    david_at_windward_dot_net
    http://www.windwardreports.com



    "David Thielen" wrote:

    > Hi;
    >
    > I have:
    > <asp:Calendar ID="mapCalendarValue" runat="server"
    > Visible="false"></asp:Calendar>
    > <asp:RequiredFieldValidator ID="mapCalValidator" runat="server"
    > ErrorMessage="RequiredFieldValidator"
    > ControlToValidate="mapCalendarValue"></asp:RequiredFieldValidator>
    >
    > which gives me:
    > [HttpException (0x80004005): Control 'mapCalendarValue' referenced by the
    > ControlToValidate property of 'mapCalValidator' cannot be validated.]
    >
    > How can I require a selected date in the calendar control?
    >
    > --
    > thanks - dave
    > david_at_windward_dot_net
    > http://www.windwardreports.com
    >
     
    David Thielen, May 28, 2006
    #2
    1. Advertising

  3. Hi David,

    Thank you for post!

    Not all Web form controls can be used in conjunction with the validation
    controls. In order to be used with the validation controls, the control
    must have a ValidationProperty attribute. The ValidationProperty attribute
    tells the validation controls the value to validate against.

    The Calendar control is one of the controls that cannot be validated in its
    original state. In many cases, however, it is necessary to be able to
    validate the user selection in the Calendar control.

    There are two solutions to this problem. The first is to write a custom
    validation control. The second is to extend the Calendar control so that it
    can be used with the built-in validation controls. Following KB article
    addresses the second solution:

    #How to extend a Web form control to work with the validation controls by
    using Visual C#
    http://support.microsoft.com/kb/310145


    Regards,
    Walter Wang
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Walter Wang [MSFT], May 29, 2006
    #3
  4. David Thielen

    swetha Guest

    Hi david ,
    I guess u need to ass a text box before ur calender and then take the
    control id on text and then validate it !
    Regards,
    M.Swetha

    "David Thielen" wrote:

    > Hi;
    >
    > I have:
    > <asp:Calendar ID="mapCalendarValue" runat="server"
    > Visible="false"></asp:Calendar>
    > <asp:RequiredFieldValidator ID="mapCalValidator" runat="server"
    > ErrorMessage="RequiredFieldValidator"
    > ControlToValidate="mapCalendarValue"></asp:RequiredFieldValidator>
    >
    > which gives me:
    > [HttpException (0x80004005): Control 'mapCalendarValue' referenced by the
    > ControlToValidate property of 'mapCalValidator' cannot be validated.]
    >
    > How can I require a selected date in the calendar control?
    >
    > --
    > thanks - dave
    > david_at_windward_dot_net
    > http://www.windwardreports.com
    >
     
    swetha, Oct 3, 2010
    #4
  5. David Thielen

    swetha Guest

    Hi david ,
    I belive u need to take a text box before ur calender and then take the
    control id on text and then validate it !
    It worked for me
    <asp:TextBox ID="txtDate"
    runat="server" PropertyName="Text"
    Text='<%# Bind("Date") %>'>
    </asp:TextBox>

    <asp:ImageButton ID="btnDate"
    runat="server" OnClick="ClickDate"
    ImageUrl="~/Images/Calendar_scheduleHS.png"
    />
    <div style ="z-index:2;
    position:absolute;top:450px; left:996px;">
    <asp:Calendar ID="TodayDate"
    OnSelectionChanged="DateEntry" runat="server" BackColor="White"
    BorderColor="#3366CC"
    BorderWidth="1px" CellPadding="1"
    DayNameFormat="Shortest"
    Font-Names="Verdana" Font-Size="8pt"
    ForeColor="#003399" Height="200px"
    Width="220px" Visible="false" DayHeaderStyle-Wrap="true">
    <SelectedDayStyle
    BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
    <SelectorStyle BackColor="#99CCCC"
    ForeColor="#336666" />
    <WeekendDayStyle
    BackColor="#CCCCFF" />
    <TodayDayStyle BackColor="#99CCCC"
    ForeColor="White" />
    <OtherMonthDayStyle
    ForeColor="#999999" />
    <NextPrevStyle Font-Size="8pt"
    ForeColor="#CCCCFF" />
    <DayHeaderStyle BackColor="#99CCCC"
    ForeColor="#336666" Height="1px" />
    <TitleStyle BackColor="#003399"
    BorderColor="#3366CC" BorderWidth="1px"
    Font-Bold="True" Font-Size="10pt"
    ForeColor="#CCCCFF" Height="25px" />
    </asp:Calendar>

    </div>

    <asp:RequiredFieldValidator ID="rfvDate"
    runat="server" Text="Please select a
    date from the calender menu!"
    ControlToValidate="txtDate">
    </asp:RequiredFieldValidator><br />
    Regards,
    M.Swetha

    "David Thielen" wrote:

    > Hi;
    >
    > I have:
    > <asp:Calendar ID="mapCalendarValue" runat="server"
    > Visible="false"></asp:Calendar>
    > <asp:RequiredFieldValidator ID="mapCalValidator" runat="server"
    > ErrorMessage="RequiredFieldValidator"
    > ControlToValidate="mapCalendarValue"></asp:RequiredFieldValidator>
    >
    > which gives me:
    > [HttpException (0x80004005): Control 'mapCalendarValue' referenced by the
    > ControlToValidate property of 'mapCalValidator' cannot be validated.]
    >
    > How can I require a selected date in the calendar control?
    >
    > --
    > thanks - dave
    > david_at_windward_dot_net
    > http://www.windwardreports.com
    >
     
    swetha, Oct 3, 2010
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AtomicBob
    Replies:
    14
    Views:
    911
    Toby Inkster
    May 2, 2006
  2. Keith-Earl
    Replies:
    3
    Views:
    518
    Keith-Earl
    Oct 26, 2004
  3. David Thielen

    Require text entry - only if radio button checked

    David Thielen, Jul 24, 2006, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    282
    David Thielen
    Aug 16, 2006
  4. Mike Owen

    Allowing entry of a Carriage Return during data entry

    Mike Owen, Jul 27, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    726
    Alessandro Zifiglio
    Jul 27, 2006
  5. Noozer
    Replies:
    2
    Views:
    266
    Dr John Stockton
    Aug 1, 2005
Loading...

Share This Page