Solved

ASP.NET

Posted on 2010-11-27
6
412 Views
Last Modified: 2012-05-10
Dear Friends,

I have an online matrimonial portal running for almost 2 years. Suddenly outoff nowhere it started giving the below error:

System.Web.HttpException: The value '28/11/1992' of the ValueToCompare property of 'cvDOB' cannot be converted to type 'Date'.     at System.Web.UI.WebControls.CompareValidator.ControlPropertiesValid()     at System.Web.UI.WebControls.BaseValidator.get_PropertiesValid()     at System.Web.UI.WebControls.BaseValidator.OnPreRender(EventArgs e)     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Control.PreRenderRecursiveInternal()     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


The error is generated from the following code:


___________   .aspx  code _____________________________

                                            <td class="W350">
                                            <div id="divCal" runat="server">
                                                <asp:TextBox ID="txtDOB" runat="server" MaxLength="12" CssClass="W100 fs12" TabIndex="2"
                                                    onfocus="enterfiled('row1');" onblur="onexit('row1');"
                                                    ></asp:TextBox>
                                                <%--<asp:HyperLink ID="imgDate" runat="server" ImageUrl="~/images/pdate.gif" NavigateUrl="">HyperLink</asp:HyperLink>--%>
                                                <cc1:CalendarExtender ID="ceDOB" runat="server" TargetControlID="txtDOB" CssClass="cal_Theme1"
                                                    PopupPosition="Left" Format="dd/MM/yyyy">
                                                </cc1:CalendarExtender>
                                                <asp:RequiredFieldValidator ID="rfvDOB" runat="server" ControlToValidate="txtDOB"
                                                    Display="None" ErrorMessage="Date Of Birth Required." SetFocusOnError="true"></asp:RequiredFieldValidator>
                                                 <cc1:ValidatorCalloutExtender ID="vceDOB" runat="server" TargetControlID="rfvDOB">
                                                </cc1:ValidatorCalloutExtender>
                                               
                                               
                                                 <asp:CompareValidator ID="cvDOB" runat="server" Operator="LessThan"
                                                     Type="Date" ControlToValidate="txtDOB" Display="None"
                                                 ErrorMessage="Member should be 18 years old at time of registration."
                                                    SetFocusOnError="true"></asp:CompareValidator>
                                                <cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" TargetControlID="cvDOB">
                                                </cc1:ValidatorCalloutExtender>
                                                <cc1:ValidatorCalloutExtender ID="vce1" runat="server" TargetControlID="cvDOB">
                                                </cc1:ValidatorCalloutExtender>
                                               </div>
                                            </td>
                                            <td class="W20">
                                                &nbsp;
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="W20">
                                                &nbsp;
                                            </td>
                                            <td class="W350">
                                                &nbsp;
                                            </td>
                                            <td class="W50">
                                            </td>
                                            <td class="W350 fs10">
                                                <asp:Label ID="lblDOBInstruct" runat="server" Text="You can use the calendar or directly type is the date of birth in the format <b>{Month / Date / Year}</b>.<br><br>Date of Birth will be used to calculate the age and will not be displayed to others. <br><br> Should me a major <b>(minimum 18 years)</b> at the time of registration."></asp:Label>
                                            </td>
                                            <td class="W20">
                                                &nbsp;


___________________ aspx.cs code____________________________



                    cvDOB.ValueToCompare = DateTime.Now.AddYears(-18).ToShortDateString();


___________________________________________

Please help and thanks for your help.



0
Comment
Question by:MadhuMenong
  • 4
  • 2
6 Comments
 
LVL 23

Accepted Solution

by:
Rajkumar Gs earned 500 total points
ID: 34224362
Seems something wrong related to date format.
Anything changed in the system for date format ?
I mean, changed format from MM/dd/yyyy to dd/MM/yyyy or something similar in date format ?

Raj
0
 

Author Comment

by:MadhuMenong
ID: 34224387
Dear RajkumarGS,
Thanks for your comments.

The application runs perfectly on my local system but when i upload to the web (using a shared server from znetindia) it throws up the error.

Was working perfectly till recently. Only thing that happened was znet did so upgrade or shifted the application to a new server and after that all problems started.

0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34224409
Hi Madhu,

If I am right, this error The value '28/11/1992' of the ValueToCompare property of 'cvDOB' cannot be converted to type 'Date'. says that '28/11/1992' is wrong. '11/28/1992' could be right based on the new server date format.

I think, the date format in your local system and the new server is different. Can you verify this ?

Raj
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:MadhuMenong
ID: 34224452

Hi Rajkumargs,

I will try that .... give me a moment please.
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34224457
Sure. :)

Raj
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34237078
Glad to help you :)

Raj
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now