Bug? ASP.Net 2 Title does not render text when it contains controls

I

Ian Dunkerly#

I am using .Net 2 SP1 and appear to have a problem with rendering titles,
when the title contains both text and a controls only the controls are
rendered.

This can be reproduced by creating a page with the following:

<%@ Page Language="C#" AutoEventWireup="true" %>

<html>
<head runat="server">
<title>Test<asp:Localize ID="Localize1" runat="server" Text="Hello"
/></title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
</form>
</body>
</html>

I would expect that TestHello would be rendered, but only Hello is rendered.

Is this a known bug, is there a hotfix?

Thanks

Ian
 
M

Michael Nemtsev [MVP]

Hello Ian Dunkerly#,

use the method call from title, like
<title><%= GetTitle() %></title>

where in your method return the string

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


I> I am using .Net 2 SP1 and appear to have a problem with rendering
I> titles, when the title contains both text and a controls only the
I> controls are rendered.
I>
I> This can be reproduced by creating a page with the following:
I>
I> <%@ Page Language="C#" AutoEventWireup="true" %>
I>
I> <html>
I> <head runat="server">
I> <title>Test<asp:Localize ID="Localize1" runat="server"
I> Text="Hello"
I> /></title>
I> </head>
I> <body>
I> <form id="form1" runat="server">
I> <div>
I> </div>
I> </form>
I> </body>
I> </html>
I>
I> I would expect that TestHello would be rendered, but only Hello is
I> rendered.
I>
I> Is this a known bug, is there a hotfix?
I>
I> Thanks
I>
I> Ian
I>
 
M

Michael Nemtsev [MVP]

Hello Ian Dunkerly#,

actually, u can put "Test" into another <asp:Localize> control and it will
be rendered

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


I> I am using .Net 2 SP1 and appear to have a problem with rendering
I> titles, when the title contains both text and a controls only the
I> controls are rendered.
I>
I> This can be reproduced by creating a page with the following:
I>
I> <%@ Page Language="C#" AutoEventWireup="true" %>
I>
I> <html>
I> <head runat="server">
I> <title>Test<asp:Localize ID="Localize1" runat="server"
I> Text="Hello"
I> /></title>
I> </head>
I> <body>
I> <form id="form1" runat="server">
I> <div>
I> </div>
I> </form>
I> </body>
I> </html>
I>
I> I would expect that TestHello would be rendered, but only Hello is
I> rendered.
I>
I> Is this a known bug, is there a hotfix?
I>
I> Thanks
I>
I> Ian
I>
 
I

Ian Dunkerly

Thanks for the replies.

I actually simplified the source to demonstrate the problem. You can use any
combination of controls and text and all the text will be stripped out.

I would have thought that the title control works in the same way as the
label control - you can set the text property, but if you add any controls
then the whole lot renders as a control hierarchy.

Ian
 
M

Michael Nemtsev [MVP]

Hello Ian,

If you put your text into asp:Literal control its not stripped out

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


ID> simplified the source to demonstrate the problem. You can use any
ID> combination of controls and text and all the text will be stripped
ID> out.
ID>
 
A

Andrew Morton

If it's any help, you can do this to a <title>:
<title runat="server" id="title">A page</title>

and declare it in the code-behind as
Public title As System.Web.UI.HtmlControls.HtmlGenericControl

and set the text with
title.InnerHtml &= " title"

Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top