|
| |
| koraykazgan | Asp.Net User |
| Localization with MasterPage | 3/18/2008 11:43:31 AM |
0 | |
|
Hi,
I have a Label inside a MasterPage, which is showing some header information. In content pages I am setting a specific value to it. To prevent me to cast the Page.Master property to my actual MasterPage and then access that label, I have created a base class for all my Content pages, called BasePage. In that I have written a property called PageTitle, which is returning the label. In every page, which is deriving from BasePage, I can do the following:
this.PageTitle = "My Title";
Afterwards, I localized my content pages. In the resource file, I have an entry like "Page.PageTitle" and set a value to it. When I do that, I don't have to do anything in code behind. The automatic localization of ASP.Net is finding the property and setting its value.
But right now, I put the label in the MasterPage inside an updatePanel (the contentpage is outside the updatepanel). When I run my app, I get an error, that the label is null. I think it is not initialized yet. Can you tell me, how can I initialize the label, before localization of the content page has begun?
There is always one more bug. |
| Amanda Wang - M | Asp.Net User |
| Re: Localization with MasterPage | 3/20/2008 6:53:51 AM |
0 | |
|
Hi,
koraykazgan: But right now, I put the label in the MasterPage inside an updatePanel (the contentpage is outside the updatepanel). When I run my app, I get an error, that the label is null.
You can try to check the label's clientID.
Sometimes, the control's clientID will be changed if you put the control in the updatepanel, it will be like: updatepanelid$labelid or updatepanelid_labelid
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 |
| koraykazgan | Asp.Net User |
| Re: Localization with MasterPage | 3/20/2008 7:41:06 AM |
0 | |
|
Hi Amanda,
I don't understand why I should use ClientID. I have created a public property in my masterpage, which is returning my label. So from my webcontentpage I can access it through the property. I don't need its clientID.
I could reproduce that problem in a simpler way:
Create a webForm and put a scriptManager, an updatePanel to the page and a label inside the update panel. Create a property named PageTitle in the code behind, which is returning the text property of the label. When you set the PageTitle property programmaticly, it is working. But when you localize the page by using "generate local resource" and put the Page.PageTitle key into the resource file, ASP is trying to assign a value to the property automatically, while the label itself is not initialized yet (of course, you have to give the page a meta:resourcekey="Page" in the page directive).
I know that this sample is not efficient, but I actualy need this in a master page scenario. This sample is only a cut down repro of the problem.
Hope you can help me.
There is always one more bug. |
| Amanda Wang - M | Asp.Net User |
| Re: Localization with MasterPage | 3/21/2008 5:13:10 AM |
0 | |
|
Hi,
Could you please post the aspx file and code here?
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 |
| koraykazgan | Asp.Net User |
| Re: Localization with MasterPage | 3/21/2008 4:51:27 PM |
0 | |
|
Hi again.
I could reproduce the same problem without a masterpage. I have just a page. On that page an updatepanel, and inside a label. In codebehind, I have defined a property, which is returning the labels text. If I set the label's text using the property by code, it is working like expected. But if I don't set it programmatically, and instead set the meta:resourcekey of the page and put a key in the local resourcefile with key [PageResourceKey].[PropertyName], I get an exception that the label is not set.
Here the markup of the page: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="UpdatePanelLocalization.TestPage" meta:resourcekey="PageResource1" %>
<% @ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %><!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>Testpage</title>
</ head>
< body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</div></form>
</ body>
</ html>
And here its code behind:
public partial class TestPage : System.Web.UI.Page
{ public string MyHeaderText
{ get { return this.Label1.Text; }set { this.Label1.Text = value; }
}
}
And I have a resource file named TestPage.aspx.resx in the App_LocalResources folder with key PageResource1.MyHeaderText and any value. When you do that and run the app, you will get an exception, that the label is not set.
There is always one more bug. |
| Amanda Wang - M | Asp.Net User |
| Re: Localization with MasterPage | 3/25/2008 8:38:50 AM |
0 | |
|
Hi,
Why do you declare a property to change the Label1.Text?
How about do it like this:
Then only add a string named MyHeaderText,
Then you use <%$ Resources:Resources: MyHeaderText %> expressions.
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label1" runat="server" Text="<%$ Resources: MyHeaderText %>"></asp:Label> </ContentTemplate> </asp:UpdatePanel>
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 |
| koraykazgan | Asp.Net User |
| Re: Localization with MasterPage | 3/25/2008 11:04:53 AM |
0 | |
|
Hi Amanda,
in my system, I have many pages. In the most of them, the header text is static. So I would just insert it into the resource file and everything will work automatically. But on some pages, the header is created on some other circumstances. There I need a property, to be able to set the header programmatically.
Do you think, it is not possible?
There is always one more bug. |
|
| |
Free Download:
Books: Practical .NET2 and C#2: Harness the Platform, the Language, the Framework Authors: Patrick Smacchia, Pages: 896, Published: 2006 Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter Kit Authors: David Sussman, Alex Homer, Pages: 312, Published: 2006 Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages Authors: Jacob J. Sanford, Pages: 474, Published: 2007 Real world SharePoint 2007: indispensable experiences from 16 MOSS and WSS MVPs Authors: Scot Hillier, Robert Bogue, Adam Buenz, Andrew Connell, Stacy Draper, Luis Du Solier Grinda, Todd O. Klindt, Jason Medero, Dustin Miller, Heather Solomon, Shane Perran, Joris Poelmans, Nick Swan, Jan Tielens, Mike Walsh, Shane Young, Pages: 478, Published: 2007 Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005 Pro ASP.NET 2.0 in VB 2005 Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006 Professional C# 2005 with .NET 3.0 Authors: Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner, Pages: 1748, Published: 2007 Pro ASP.NET 2.0 in VB 2005: special edition. Authors: Laurence Moroney, Matthew MacDonald, Pages: 1360, Published: 2006 ASP.NET 2.0 Black Book Authors: Dreamtech Software, Charul Shukla, Dreamtech Software India, Anil Kumar Barnwal, Pages: 1167, Published: 2006 Beginning Expression Web Authors: Zak Ruvalcaba, Pages: 474, Published: 2007 Web:CodeProject: Globalization & Localization with Master page. Free ... This article includes the precise implementation description of multiple cultures in a single application; Author: Aqeel Khandwala; Section: ASP. Using Localization in the MasterPage and other pages (VB-sample ... NET, ASP, global.asax, localization, masterpage, Session, vb, Web Developer. You can follow any responses to this entry through the RSS 2.0 feed. ... MasterPages Localization/Globalization & resources issue - ASP.NET ... Please note, I tracked culture - and its okey. Its changed as requested. But User Controls, Controls in Master Page IS NOT localized. ... C#.NET Localization with MasterPage | Mike Tutorial on how to make a C#.NET Website using Localization and MasterPages. .NET ASP.NET Localization + Master Page Localization + Master Page - cti. 07-May-07 09:55:26. Hello I'm building a multilingual application with .NET Framework 2.0. When I use the "generate local ... Masterpage and Localization - ASP.NET Forums I have some problems using Masterpage and Localization together, but then I found this solution: http://forums.asp.net/1219973/ShowPost.aspx ... DotNetSlackers: Develop ASP.NET with MasterPage and Localization NET with MasterPage and Localization. Posted by: The Code Project Latest Articles, on 08 May 2008 | View original. The MasterPage is derived from ... DevASP.Net Globalization & Localization with Master page Master Pages Globalization & Localization with Master page Master Pages Directory of ASP.NET, VB.NET, C#, XML and SQL resources, articles, samples, tutorials, scripts, ... Applying localization From MasterPages The scenario here is I want to apply localization to my web application and place language selection on MasterPage. I have made my own solution and applied ... Applying localization with MasterPages Feb 18, 2008 ... Applying localization with MasterPages Where Language Selection control is placed in the MasterPage. |
|
|
|