English 中文(简体)
B. 现场定位的负荷
原标题:load different css for site localization

我需要根据用户选择的语言装上不同的卷宗。 我只需要在我的主页上这样做。

最佳回答

如果你使用内在主题和全球化支持的话,你可以使用http://Module:(未经测试)

public class PageModule : IHttpModule
{


public void Dispose()
{
}


public void Init(System.Web.HttpApplication context)
{
    context.PreRequestHandlerExecute += Application_PreRequestHandlerExecute;

}

public void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
    //Adds a handler that executes on every page request
    HttpApplication application = default(HttpApplication);
    application = (HttpApplication)sender;

    Page page = application.Context.CurrentHandler as Page;

    if ((page != null))
        page.PreInit += Page_PreInit;

}


public void Page_PreInit(object sender, EventArgs e)
{
    //If current context has no session then abort
    if (HttpContext.Current.Session == null)
        return;

    //Get current page context
    Page page = (Page)sender;

    switch (page.Culture) {
        case "en-US":
            page.Theme = "en-USTheme";
            break;
        case "fr-FR":
            page.Theme = "fr-FRTheme";
            break;
        default:
            page.Theme = "DefaultTheme";
            break;
    }

}

}
问题回答

您可以用 co语书写选定的语言。 然后,在主页上检查在 co子中节省的价值,并分配正确的风格。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签