locked
Page Title from Resource file... RRS feed

  • Question

  • User-230431284 posted

    Hello,

    I have Resource file...

    I am using following code for Display Lable Text...

    <asp:Label ID="lblName" runat="server" Text="<%$ Resources:resource,NAME %>"></asp:Label>

    and I want to use that name for page title...

    so I used "me.page.resources.resource.NAME" in code behind page.

     but I want to use that NAME in

    <%@ Page Language="VB" MasterPageFile="~/Master.master" AutoEventWireup="false" CodeFile="Default.aspx.vb"

    Inherits="DefaultPage" Title="<%$ Resources:resource,NAME %>"%>

     Is there any way????

    Please help me...

     

    Thanks,

    Sachin.

    Monday, January 21, 2008 2:30 AM

Answers

All replies

  • User-503940700 posted

    Refer this article for localizing title using auto generated resx files:

    http://aspalliance.com/423_Localization_in_ASPNET_20_and_Visual_Studio_NET_2005__Code_free_Localization

    You can also set the title in the code behind as shown above.

    HTH,

    Vivek

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 21, 2008 3:03 AM
  • User-230431284 posted

    Hey Thanks Vivek,

    I dont want to using Localization here....

    I am reading string from App_GlobalResources(Resource.resx) .

    here I get Page Title from Resource.resx....

     <%@ Page Language="VB" MasterPageFile="~/Master.master" AutoEventWireup="false" CodeFile="Default.aspx.vb"

    Inherits="DefaultPage" Title="<%$ Resources:resource,NAME %>"%>

    But, my problem is... I want to show <%$ Resources:resource,NAME %> + "Page"

    e.g. ....<%$ Resources:resource,NAME %>=Yahoo + "Page" i.e. Yahoo Page

    If I use Title="<%$ Resources:resource,NAME %>" It shows page title as it is..

    Thanks 1s again,

    Sachin.

    Monday, January 21, 2008 3:49 AM
  • User-1509636757 posted

    <%$ Resources:resource,NAME %>=Yahoo + "Page" i.e. Yahoo Page
     

    it would not allow to append "Page" in Page directive... so, better to have another string resource for Page titles or try it in code behind (page_load) event...

    C#

        this.Title = Resources.Resource.NAME + " Page"; 

    VB

        Me.Title = Resources.Resource.NAME & " Page";

    Monday, January 21, 2008 4:38 AM
  • User-230431284 posted

    Hey Thanks KaushaL....

    Yes, I did that....

    But I want to do in .aspx page(<%@ Page %> tag...[:)] )

    Thanks.

    Monday, January 21, 2008 4:44 AM
  • User-230431284 posted

    Hello,

    Any 1 nos about this.............

     

     

    Tuesday, January 22, 2008 1:50 AM
  • User-393676364 posted

    Hi Sachin,

    Do it as the following way 

     <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title id= "TestPage" title="<%$ Resources:resource,NAME %> + page"">Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
        </div>
        </form>
    </body>
    </html>

    I think it will help you..

    Thanks,
    Satish. 

    Friday, January 25, 2008 4:50 AM
  • User-230431284 posted

    Hey Thanks Satish...

    Yes, I did that....

    But I want to do in .aspx page(<%@ Page %> tag...Smile )

    Thanks 1s again.....

    Sunday, January 27, 2008 10:46 PM
  • User1215786134 posted

     Sachin, did you ever find the solution to this? I would like to accomplish the same thing by putting it within the page directives at the top.

     

    Thanks,

    zero 

    Saturday, February 2, 2008 12:01 PM
  • User-230431284 posted

    Still No zero [:(]

    Sunday, February 3, 2008 8:40 AM
  • User-503940700 posted

     Why dont suffix "Page" in the resource file itself? That would save you the effort!

    Hope this helps,

    Vivek 

    Monday, February 4, 2008 2:16 AM
  • User-230431284 posted

    Hi,

    Any 1 nos about this.............

    Friday, May 30, 2008 3:36 AM
  • User2006178999 posted

    Dude, if <%$ Resources:key %> doesn't work, then might need to define it in the html.

    eg:
     

    EDIT: the editor is chewing up my html :(

    take 3...

    < html >
        < head >
            < title ><$ Resources:Key %> Page< /title >
        < /head >
    ...
    ..

    Sunday, June 1, 2008 8:58 AM
  • User-230431284 posted

    hey thx buddy,

    but i'm using Master pages.... so hw can i????

     

    Thanks,

    Sachin.

    Sunday, June 1, 2008 9:23 AM
  • User1424575140 posted

    If you use local resources, then you can use meta:ResourceKey (Use Tools| GenerateLocalResourcee)

    If you are using global resources, you can set the title with a resource expression : Title="<%$Resources:ColumnHeaders, Price %>"

    This requires that the head be runat=server

    <head runat="server">
        <title>Untitled Page</title>
    </head>

    Tuesday, June 3, 2008 3:27 PM
  • User392033127 posted

    Hi,

    I know once simple method.

    In your resource file keep the key name as MyPage.Title

    Then in your asp.net page you can simple write like below.

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="MyPage.aspx.cs" Inherits="CreateNetExposure" Theme="EMSUI" meta:resourcekey="MyPage" %>

    This will automatically will apply the Title to the page

    Note: In the above scenario, you will have to keep your resource file name same as ur aspx page name that means: MyPage.aspx.resx

    Best Regards

    Tuesday, August 18, 2009 5:42 AM
  • User392033127 posted

    Hi,

    I know one simple method.

    In your resource file keep the key name as MyPage.Title

    Then in your asp.net page you can simple write like below.

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="MyPage.aspx.cs" Inherits="CreateNetExposure" Theme="EMSUI" meta:resourcekey="MyPage" %>

    This will automatically will apply the Title to the page

    Note: In the above scenario, you will have to keep your resource file name same as ur aspx page name that means: MyPage.aspx.resx

    Best Regards

    Tuesday, August 18, 2009 5:42 AM
  • User-1179402742 posted

    Please use following steps to use local resources to set content page's
    title:
    1) In the folder where the content page resides, create a subfolder
    "App_LocalResources" if it doesn't exist yet;
    2) In the subfolder, create a resource file named after the content page
    file name, for example: "Default2.aspx.resx", and create a resource key
    "PageTitle", set its content to your desired page title.
    3) In the content page declaration, use following code to use the resource:

    <%@ Page Language="C#" MasterPageFile="~/MasterPage.master"
    UICulture="auto" AutoEventWireup="true" CodeFile="Default2.aspx.cs"

    Inherits="Default2" Title="<%$ Resources:PageTitle %>" %>

    If you want to add additional languages, just add more
    "Default2.aspx.??.resx" to the "App_LocalResources" subfolder. You also
    need to set UICulture="auto" in the @ Page directive or include a
    <globalization  uiCulture="auto"/> element in web.config if you need to use
    different resources by client browser settings.

    Hope this helps. Please feel free to post here if anything is unclear.


    Wednesday, April 28, 2010 4:04 AM
  • User1848632812 posted

    Hi, Please use Literal Control between title tags to set title text from Resources. 


    Example:



    <title>
    
    <asp:Literal ID="myLiteral" runat="server" Text="<%$ Resources:yourResource, yourResourceName %>"></asp:Literal>
    
    </title>



    Thursday, August 19, 2010 3:37 PM