locked
Globalization and Localization RRS feed

  • Question

  • User406617127 posted

    i want to change the textbox value dynamically in given cluture  with out
    passing the control value in resource file.


    <table border="0" cellpadding="0" cellspacing="0" style="width: 50%">
                <tr>
                    <td style="width: 100px"></td>
                    <td style="width: 100px"></td>
                </tr>
                <tr>
                    <td style="width: 100px">&nbsp;Insert Text</td>
                    <td style="width: 100px">
                        <asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox></td>
                </tr>
                <tr>
                    <td style="width: 100px"></td>
                    <td style="width: 100px">
                        <asp:Button ID="Button1" runat="server"  OnClick="Button1_Click"
                            Text="Button" /></td>
                </tr>
                <tr>
                    <td colspan="2" style="height: 19px">
                        <asp:Label ID="lblMessage" runat="server" Visible="false"></asp:Label></td>
                </tr>
            </table>

    ---------

    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Threading;
    using System.Drawing;
    using System.Globalization;

    public partial class Default3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("hi-IN");
            Thread.CurrentThread.CurrentCulture = new CultureInfo("hi-IN");
            System.Globalization.CultureInfo cInfo = new System.Globalization.CultureInfo("hi-IN");
            string str = TextBox1.Text;
            lblMessage.Visible = true;
            lblMessage.Text = str.ToString(cInfo);
        }
    }

    plz help out

    Thanks

    Wednesday, July 22, 2009 1:47 AM

Answers

  • User-25924017 posted

    string.ToString(cultureinfo) does nothing at the moment. How come string "The Nederland" will be written in hi-IN culture, automatically like द नेदरलेंड ? you need to provide translation using resource files.

    string.ToString(IformatProvider), this is reserved, it will do nothing in converstion but if you have

    DateTime.ToString() or Int.ToString() or Double.ToString() with culture info, data type will be formated.

    So determine what type of data type, TextBox contains and accordingly use that method with culture specific formatting else if its just string then use resource file.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 22, 2009 10:14 AM