PDA

View Full Version : [CLOSED] The page title gets wiped out



bogc
Mar 12, 2013, 6:34 PM
I have a strange issue which didn't use to occur in Ext.Net 1.x. The page title gets wiped out. If I remove the ResourceManager from Page.Master the title shows up.

Page.Master:


<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Page.master.cs" Inherits="Ext.Net.Examples.Page" %>

<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

<!DOCTYPE html>
<html>
<head runat="server">
<title>Test</title>
</head>
<body>
<ext:ResourceManager ID="ResourceManager" runat="server" ScriptMode="Debug" SourceFormatting="true" Namespace="App" IDMode="Predictable"/>

<div>
<asp:ContentPlaceHolder ID="PageContent" runat="server">

</asp:ContentPlaceHolder>
</div>



</body>
</html>

TestPage.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Page.Master" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="Ext.Net.Examples.TestPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PageContent" runat="server">
</asp:Content>


This gets rendered to:


<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="/extjs/resources/css/ext-all-gray-embedded-css/ext.axd?v=21661" id="ext-theme" />
<link type="text/css" rel="stylesheet" href="/extnet/resources/css/extnet-all-embedded-css/ext.axd?v=21661" />
<script type="text/javascript" src="/extjs/ext-all-debug-js/ext.axd?v=21661"></script>
<script type="text/javascript" src="/extnet/extnet-all-debug-js/ext.axd?v=21661"></script>

<title></title>

<script type="text/javascript">
//<![CDATA[
Ext.net.ResourceMgr.init({
id: "ctl00$ResourceManager",
theme: "gray"
});Ext.onReady(function(){});
//]]>
</script>
</head>
<body>


<div>


</div>



</body>
</html>

If I remove the ResourceManager, TestPage.aspx gets rendered to:


<!DOCTYPE html>
<html>
<head><title>
Test
</title></head>
<body>


<div>


</div>



</body>
</html>


It looks to me as if the ResourceManager wipes out the title in this specific context.

Any ideas?

Thank you

bogc
Mar 12, 2013, 7:12 PM
After digging more into it, I noticed that the title can be set in TestPage.aspx in the Page directive.


<%@ Page Title="MyTitle" Language="C#" MasterPageFile="~/Page.Master" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="Ext.Net.Examples.TestPage" %>

My problem was that I wanted the title to be dynamic based on the user language, so I ended up removing the Title attribute (if you don't remove it, it won't work) from the Page directive and set the title in the Page_Load function through code (in TestPage.aspx).


<%@ Page Language="C#" MasterPageFile="~/Page.Master" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="Ext.Net.Examples.TestPage" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{

this.Page.Title = "My awesome title";
}

</script>
<asp:Content ID="Content1" ContentPlaceHolderID="PageContent" runat="server">
</asp:Content>


But what if I want to set the same title for all the pages using the master template?

I also found the code which I think it might be responsible with this in ResourceManager.cs:


if (!this.IsSelfRender && this.Page.Header != null)
{
writer.Write(Transformer.NET.Net.CreateToken(typeo f(Transformer.NET.ItemTag), new Dictionary<string, string> { { "selector", "fixTitle" } }, "\n <title>{0}</title>\n ".FormatWith(this.Page.Title)));
}

I am using the official version 2.1.1.

jchau
Mar 12, 2013, 11:25 PM
i think it's an issue with asp.net and masterpages. Like you, I removed all Title="" from the aspx markup pages and just warned the team to do the same when they create new content pages.

Baidaly
Mar 12, 2013, 11:57 PM
Hello!

Thank you @jchau, you are right.

@bogc, where do you want to set Title? Because in your case you override MasterPage's title using Title attribute in Page directive:


<%@ Page Title="" Language="C#" MasterPageFile="~/Page.Master" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="Ext.Net.Examples.TestPage" %>

bogc
Mar 13, 2013, 12:09 AM
I wanted to set the title in the master.

@jchau: I didn't have this issue when I used Ext.Net 1.x.

Baidaly
Mar 13, 2013, 12:28 AM
I wanted to set the title in the master.


So just remove Title="" from there:


<%@ Page Title="" Language="C#" MasterPageFile="~/Page.Master" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="Ext.Net.Examples.TestPage" %>

bogc
Mar 13, 2013, 1:09 AM
Yes. You can close the thread.

Thank you