Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7954847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:33:22+00:00 2026-06-04T03:33:22+00:00

I have a textbox with a calendar extender. The format should be like this:

  • 0

I have a textbox with a calendar extender.

The format should be like this:

<add key="DateFormat" value="dd/MM/yyyy"/>

I have the following on my aspx markup

  <asp:TextBox ID="txt" runat="server" 
                        meta:resourcekey="txt" MaxLength="150" HtmlEncode="False"></asp:TextBox>
                        <ajaxToolkit:CalendarExtender runat="server"
                            TargetControlID="txt"
                                            PopupButtonID="Image1" Format="<%$Appsettings:DateFormat%>" />

WHen I try to use it in a property like this:

datett= DateTime.Parse(txt.Text),

It says FormatException.

I debugged and also tried Convert.ToDatetime, same exception raised.

The text I am testing is 30/05/2015

which according to my format in my web.config should work fine.

update1
I use the following code to change the language and culture of my page based on user selection, maybe this is why its failing,

I see many answers, the 2nd question would be, how to get the current culture?

/// <summary>
        /// Handles the AcquireRequestState event of the Application control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Application_AcquireRequestState(object sender, EventArgs e)
        {
            //Create culture info object 
            /*var ci = new CultureInfo(Session["Language"].ToString());
            System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ci.Name);*/

            System.Web.UI.Page p = (System.Web.HttpContext.Current.Handler as System.Web.UI.Page);
            if (p != null)
            {
                p.UICulture = p.Culture = new CultureInfo((string)Session["Language"]).Name;
            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:33:24+00:00Added an answer on June 4, 2026 at 3:33 am

    You could use DateTime.ParseExact and/or pass the culture explicitely:

    var enCulture = new System.Globalization.CultureInfo("en-us");
    DateTime result = DateTime.ParseExact("30/05/2015", 
                                          "dd/MM/yyyy", 
                                           enCulture );
    

    Edit: If you’re dynamically changing the culture and storing it in Session, this should work:

    var userCulture = new System.Globalization.CultureInfo((string)Session["Language"]);
    DateTime result = DateTime.Parse(TxtVehicleDestructionDateReturnedVehicle.Text, userCulture );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textbox and a calendar extender, here's the code in page Default.aspx:
i have a textbox associated with a calendar extender and a masked edit extender
I have a calendar extender addHoliday, but every time I select a value and
I have code like this on some aspx page in my Web Application: <asp:Content
I have a textbox that is wired up to a calendar control like so
I have a text box which has a Ajax calendar extender attached. You click
I have a textbox which is extended by an Ajax Control Toolkit calendar. I
I have a textbox.In its onclick iam calling a javascript fn to call calendar.Texbox
I have a composite drop down calendar user control that consists of a textbox
Im creating forum like application and I have textbox where users can enter tags

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.