从 aspx 设置多语言页面标题

发布于 2024-10-01 02:02:15 字数 793 浏览 1 评论 0原文

我问了几个关于 ASP.NET 中的多语言的问题,我非常感激,因为答案很有帮助。

我现在面临另一个问题。

我有页面指令:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="Galeria.aspx.cs" Inherits="TerapiaFisica.Galeria" %>

我想要的是使标题成为多语言。
我知道我可以通过代码隐藏来做到这一点,如下所示:

protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = (string)GetLocalResourceObject("PageTitle");
    }

但这正是我不想做的。我想通过 aspx 的页面指令中的标签使该标题成为多语言。

谁能告诉我该怎么办?
我尝试了这两个选项,但没有一个有效:

<%@ Page Title=" <%= GetGlobalResourceObject("Global", "PageTitle") %>"

<%@ Page Title="<asp:Localize Text="<%$ Resources: Global, PageTitle %>"

I had asked a couple of question about multilanguage in asp.net and I am very grateful because the answers have been of much help.

I now face another problem.

I have the page directive:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="Galeria.aspx.cs" Inherits="TerapiaFisica.Galeria" %>

What I want is to make the Title multilanguage.
I know i can do that from code behind with something like this:

protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = (string)GetLocalResourceObject("PageTitle");
    }

But that's exactly what i don't want to do. I want to make that title multilanguage from the tag in the page directive of the aspx.

Anyone can tell me what to do?
I tried this two options but none of them works:

<%@ Page Title=" <%= GetGlobalResourceObject("Global", "PageTitle") %>"

and

<%@ Page Title="<asp:Localize Text="<%$ Resources: Global, PageTitle %>"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请止步禁区 2024-10-08 02:02:16

这对你有用吗?

<head>
    <title><%= GetGlobalResourceObject("Global", "PageTitle") %></title>
</head>

Will this work for you?

<head>
    <title><%= GetGlobalResourceObject("Global", "PageTitle") %></title>
</head>
瑾兮 2024-10-08 02:02:16

我面前没有 IDE,但你写的(下面)看起来错误

<%@ Page Title=" <%= GetGlobalResourceObject("Global", "PageTitle") %>"

你尝试过吗

<title>
    <%= GetGlobalResourceObject("Global", "PageTitle") %>
<title>

I don't have my IDE in front of me, but the one you wrote (below) looks wrong

<%@ Page Title=" <%= GetGlobalResourceObject("Global", "PageTitle") %>"

Did you try

<title>
    <%= GetGlobalResourceObject("Global", "PageTitle") %>
<title>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文