如何在ASP.Net中使用hi-IN(印度 - 印度)文化? [英] How to used of hi-IN (Hindi-India) culture in ASP.Net..?

查看:72
本文介绍了如何在ASP.Net中使用hi-IN(印度 - 印度)文化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ASP.Net中是否不支持hi-IN(印地文 - 印度文化)???

当我使用Internet Explorer 8,9



它可以用IE7 ....我是新的请给你的看法如何使用文化的所有浏览器兼容性...

i在我的基页中使用此代码。 ...







Is there no support for hi-IN (Hindi-India) culture in ASP.Net ???
When I move on Internet Explorer 8,9

it is ok with IE7....I am new Please give your view how to use culture for all browser compatibility ...
i used in my base page this code....



using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Globalization;
using System.Threading;

/// <summary>
/// Summary description for BasePage
/// </summary>
public class BasePage:System.Web.UI.Page
{
    public const string LanguageDropDownID = "ctl00$ddlLanguage";
    public const string PostBackEventTarget = "__EVENTTARGET";
    public static CultureInfo Culture;
    public static DateTimeStyles Style;
    public BasePage()
    {
        //
        // TODO: Add constructor logic here
        //
        /*if (DateTime.Now < DateTime.Parse("03/31/2014") && DateTime.Now > DateTime.Parse("01/01/2010"))
        {
            Culture = CultureInfo.CreateSpecificCulture("en-GB");
            Style = DateTimeStyles.None;

        }
        else
            throw new Exception("Server is Responding Please Contact to Server Operater");*/
    }
   protected override void InitializeCulture()
    {
        /////////<REMARKS>
        ///Check if PostBack occured. Cannot use IsPostBack in this method
        ///as this property is not set yet.
        //////</REMARKS>
        if (Request[PostBackEventTarget] != null)
        {
            string controlID = Request[PostBackEventTarget];
            if (controlID.Equals(LanguageDropDownID) || controlID.Equals("ddlLanguage"))
            {
                Session["LanguageChanged"] = true;
                string selectedValue = Request.Form[Request[PostBackEventTarget]].ToString();
                switch (selectedValue)
                {
                    case "1": SetCulture("en-GB", "en-GB");
                        break;
                    case "2": SetCulture("hi-IN", "hi-IN");
                        break;
                    default: break;

                }
            }
            else
                Session["LanguageChange"] = false;

        }
        else if (Session["MyUICulture"] == null)
        {
            SetCulture("hi-IN", "hi-IN");
            Session["LanguageChanged"] = false;

        }
        else
            SetCulture(Session["MyUICulture"].ToString(), Session["MyUICulture"].ToString());

        ///<remarks>
        ///Get the culture from the session if the control is tranferred to a
        ///new page in the same application.


            if(Session["MyUiCulture"] !=null && Session["MyUICulture"]!=null)
            {
                Thread.CurrentThread.CurrentUICulture=(CultureInfo)Session["MyUICulture"];
                Thread.CurrentThread.CurrentCulture=(CultureInfo)Session["MyCulture"];
            }
        base.InitializeCulture();
    }



    /// Sets the current UICulture and CurrentCulture based on the arguments

    protected void SetCulture(string name, string local)
    {
        Thread.CurrentThread.CurrentUICulture = new CultureInfo(name);
        Thread.CurrentThread.CurrentCulture = new CultureInfo(local);
        ///<remarks>
        ///Saving the current thread's culture set by the User in the Session
        ///so that it can be used across the pages in the current application.

        Session["MyUICulture"] = Thread.CurrentThread.CurrentUICulture;
        Session["MyCulture"] = Thread.CurrentThread.CurrentCulture;
    }
    protected void Page_PreInit(Object sender, EventArgs e)
    {

        if(Session["MyUICulture"]!= null)
        {
            if (Session["MyCulture"].ToString() == "hi-IN")
                this.Page.Theme = "Hindi";
            else
                this.Page.Theme = "English";

        }
        else
             this.Page.Theme="English";

    }
}

推荐答案

ddlLanguage;
< span class =code-keyword> public const string PostBackEventTarget = __ EVENTTARGET;
public static CultureInfo文化;
public static DateTimeStyles样式;
public BasePage()
{
// < span class =code-comment>
// TODO:在这里添加构造函数逻辑
//
/ * if (DateTime.Now< DateTime.Parse(03/31/2014)&& DateTime.Now> DateTime.Parse(01/01/2010))
{
Culture = CultureInfo.CreateSpecificCulture(en-GB);
Style = DateTimeStyles.None;

}
else
抛出新的异常(服务器响应请联系服务器操作员); * /

}
< span class =code-keyword> protected 覆盖 void InitializeCulture()
{
/// ////// < ; 备注 >
/// 检查是否发生了PostBack。由于此属性尚未设置,因此无法在此方法中使用IsPostBack
///
/// /// < / REMARKS >
if (Request [PostBackEventTarget]!= null
{
string controlID = Request [PostBackEventTarget];
if (controlID.Equals(LanguageDropDownID)|| controlID.Equals( ddlLanguage))
{
会话[ LanguageChanged] = true ;
string selectedValue = Request.Form [Request [PostBackEventTarget]]。ToString();
switch (selectedValue)
{
case 1:SetCulture( en-GB en-GB);
break ;
case 2 :SetCulture( hi-IN hi-IN);
break ;
默认 break ;

}
}
else
会话[ LanguageChange] = false ;

}
else if (会话[ MyUICulture] == null
{
SetCulture( hi-IN hi-IN);
会话[ LanguageChanged] = false ;

}
else
SetCulture(会话[ MyUICulture]。ToString(),Session [ MyUICulture]的ToString());

/// < 备注 >
/// 如果控件转移到
//从会话中获取文化/ 同一应用程序中的新页面。


if (会话[ < span class =code-string> MyUiCulture
]!= null && Session [ MyUICulture]!= null
{
Thread。 CurrentThread.CurrentUICulture =(CultureInfo)Session [ MyUICulture];
Thread.CurrentThread.CurrentCulture =(CultureInfo)会话[ MyCulture];
}
base .InitializeCulture();
}



/// 设置当前UICulture和CurrentCulture基于参数

protected void SetCulture( string name, string local)
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo(name);
Thread.CurrentThread.CurrentCulture = new CultureInfo(local);
/// < 备注 >
/// 保存用户在会话中设置的当前线程的文化
/// ,以便可以在当前应用程序的各个页面中使用它。

会话[ MyUICulture] = Thread.CurrentThread .CurrentUICulture;
会话[ MyCulture] = Thread.CurrentThread.CurrentCulture;
}
受保护 void Page_PreInit(对象发​​件人,EventArgs e)
{

if (会话[ MyUICulture]!= null
{
if (会话[ MyCulture ] .ToString()== hi-IN
this .Page.Theme = 印地语;
else
this .Page.Theme = 英文;

}
其他
.Page。 Theme = 英语;

}
}
ddlLanguage"; public const string PostBackEventTarget = "__EVENTTARGET"; public static CultureInfo Culture; public static DateTimeStyles Style; public BasePage() { // // TODO: Add constructor logic here // /*if (DateTime.Now < DateTime.Parse("03/31/2014") && DateTime.Now > DateTime.Parse("01/01/2010")) { Culture = CultureInfo.CreateSpecificCulture("en-GB"); Style = DateTimeStyles.None; } else throw new Exception("Server is Responding Please Contact to Server Operater");*/ } protected override void InitializeCulture() { /////////<REMARKS> ///Check if PostBack occured. Cannot use IsPostBack in this method ///as this property is not set yet. //////</REMARKS> if (Request[PostBackEventTarget] != null) { string controlID = Request[PostBackEventTarget]; if (controlID.Equals(LanguageDropDownID) || controlID.Equals("ddlLanguage")) { Session["LanguageChanged"] = true; string selectedValue = Request.Form[Request[PostBackEventTarget]].ToString(); switch (selectedValue) { case "1": SetCulture("en-GB", "en-GB"); break; case "2": SetCulture("hi-IN", "hi-IN"); break; default: break; } } else Session["LanguageChange"] = false; } else if (Session["MyUICulture"] == null) { SetCulture("hi-IN", "hi-IN"); Session["LanguageChanged"] = false; } else SetCulture(Session["MyUICulture"].ToString(), Session["MyUICulture"].ToString()); ///<remarks> ///Get the culture from the session if the control is tranferred to a ///new page in the same application. if(Session["MyUiCulture"] !=null && Session["MyUICulture"]!=null) { Thread.CurrentThread.CurrentUICulture=(CultureInfo)Session["MyUICulture"]; Thread.CurrentThread.CurrentCulture=(CultureInfo)Session["MyCulture"]; } base.InitializeCulture(); } /// Sets the current UICulture and CurrentCulture based on the arguments protected void SetCulture(string name, string local) { Thread.CurrentThread.CurrentUICulture = new CultureInfo(name); Thread.CurrentThread.CurrentCulture = new CultureInfo(local); ///<remarks> ///Saving the current thread's culture set by the User in the Session ///so that it can be used across the pages in the current application. Session["MyUICulture"] = Thread.CurrentThread.CurrentUICulture; Session["MyCulture"] = Thread.CurrentThread.CurrentCulture; } protected void Page_PreInit(Object sender, EventArgs e) { if(Session["MyUICulture"]!= null) { if (Session["MyCulture"].ToString() == "hi-IN") this.Page.Theme = "Hindi"; else this.Page.Theme = "English"; } else this.Page.Theme="English"; } }


您需要将Page.UICulture设置为in,然后在以下位置创建资源页面当地资源如下:

default.aspx.in.resx
you need to set Page.UICulture as "in" and then create a resource page at local resouce like this:
default.aspx.in.resx


这篇关于如何在ASP.Net中使用hi-IN(印度 - 印度)文化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆