How to get months names

Posted on 2011-10-03
Last Modified: 2012-05-12
hi i build this function below to populate an dropdownlist:

        Dim dt As System.Globalization.DateTimeFormatInfo = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat
        Dim ditem As New ListItem
        ditem.Text = "Mês"
        ditem.Value = -1
        ditem.Selected = True
        For t As Integer = 1 To 12
            Dim ditem2 As New ListItem
            ditem2.Text = dt.GetAbbreviatedMonthName(t)
            ditem2.Value = t
            ditem2.Selected = False

but the months are in english, and i want the months to be on the language that the user has choose on his computer or webbrowser.

any help?
Question by:rafaelrgl
    LVL 7

    Expert Comment

    I think the problem lies in your instantiation of the DateTimeFormatInfo object.  I haven't looked it over enough to know just why, but I believe instantiating your own object will always create an English version.  There is a static method that uses the currently set culture:

    ditem2.Text = System.Globalization.DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName(t);
    LVL 1

    Author Comment

    sorry, did not work. any other suggestion?
    LVL 7

    Accepted Solution

    I actually ran it myself; it works.

    Perhaps you didn't properly set the culture?  I think you can do it either via Web.config, or programmatically (override Page.InitializeCulture, I believe).
    LVL 1

    Author Closing Comment


    Featured Post

    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.

    Join & Write a Comment

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    729 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

    19 Experts available now in Live!

    Get 1:1 Help Now