multi lang. site with master page - page title problem

Last post 05-13-2008 12:46 AM by TOMCIO. 4 replies.

Sort Posts:

  • multi lang. site with master page - page title problem

    05-08-2008, 11:03 PM
    • Loading...
    • TOMCIO
    • Joined on 07-12-2003, 6:19 AM
    • Chicago
    • Posts 533

    my master page takes Title from resource file based on lang. ver

    <title>

    <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:Resources, mp_title %>"></asp:Literal>

    </title>

    Works perfect on all pages, but now on "product details page" i want to change title to the name of the product.
    in page load :

    page.title = "New Page title"

    doesn't work. When i change title in master page to some static text , everything works

     

     

     

     

  • Re: multi lang. site with master page - page title problem

    05-09-2008, 10:22 AM

    It might just be an event ordering thing (I can't remember when the page title is actually set). Try moving your code that changes the title from the Page_Load event to Page_PreRender event.

  • Re: multi lang. site with master page - page title problem

    05-09-2008, 11:33 AM
    • Loading...
    • TOMCIO
    • Joined on 07-12-2003, 6:19 AM
    • Chicago
    • Posts 533

    no, it did not help.

    i think it is because this (in masterpage):
     

    <title>

    <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:Resources, mp_title %>"></asp:Literal>

    </title>

    when i change it to static text, and then try to change title in page load event works ok.

  • Re: multi lang. site with master page - page title problem

    05-12-2008, 10:54 PM
    Answer

    Hi,

    I would suggest that  you can try to edit the Literal's text in the content page's codebehind, first, you can expose the literal that is in the title section as a public property in the master page'a codebehind:

    for example:

     public Literal literal
        {
            get
            {
                return this.Literal1;
            }
        }

    then add the @MasterType directive for the content page :

    <%@ Page Language="C#" Title="My Page" MasterPageFile="~/Menu/Cases/Cases/case13/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Menu_Cases_Cases_case13_Default" culture="auto" meta:resourcekey="PageResource1" uiculture="auto" %>
    <%@ MasterType VirtualPath="~/Menu/Cases/Cases/case13/MasterPage.master" %>

    So, you can edit the literal in the contentpage's codebehind:

    protected void Page_Load(object sender, EventArgs e)
        {
                this.Master.literal.Text = "My Page";
        }

    This works on my local.

    Hope it helps.

     

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Yours sincerely,
    Amanda Wang
    Microsoft Online Community Support
  • Re: multi lang. site with master page - page title problem

    05-13-2008, 12:46 AM
    • Loading...
    • TOMCIO
    • Joined on 07-12-2003, 6:19 AM
    • Chicago
    • Posts 533

    thank you - it works . i just changed it to vb but that is the solution i was looking for - thanks one more time :)

     

Page 1 of 1 (5 items)
Microsoft Communities
Page view counter