Solved

response.write title of the page

Posted on 2009-04-07
5
332 Views
Last Modified: 2012-05-06
when i do this <title><%=PageTitle%></title> and then view source of the page in a browser the title looks like this:
 <title>
      Some title
</title>

basically a lot of white space is inserted on each end and title itself is on a new line, i tried to fix it by doing this in the <head><%=PageTitle%></head> section, but when i do this i get two titles
<title>some title</title> <--- my title
<title></title> and this title is added by a browser probably, i think it detects that there is no <title> tag and just adds it to a page

i don't think that it should be a problem for SEO to remove white space, new line and parse out my title but still i want it to be neat ...
0
Comment
Question by:TransBind
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
ppittle earned 250 total points
ID: 24093825
TransBind,

Well this doesn't let you set the Page Title Declaratively, have you tried setting it in Code-Behind using the Page.Title property?  

http://msdn.microsoft.com/en-us/library/system.web.ui.page.title(VS.80).aspx
0
 
LVL 7

Author Comment

by:TransBind
ID: 24093914
if i erase title tags and integrate below code, my title looks like this:
<title>
      some title
</title>

I am starting to think that .net defaults title of the page to separate line - it is a default behavior. I always thought it should be <title>some title</title> - no white space, or new lines ...

protected void Page_Load(object sender, EventArgs e)
{
   Page.Title = "some title";
}

0
 
LVL 8

Expert Comment

by:ppittle
ID: 24094156
One other you might try is adding the runat attribute to the title tag:
<title runat="server"><%=PageTitle%></title>

That might change how the Page is rendered and the HTML markup that results.  Otherwise, I can't think of a good work around.  .NET has been known for spitting out markup that isn't the prettiest and doesn't always meet certain standards.  Unfortunatly, there's really not a whole lot that can be done about it.

PJ
0
 
LVL 6

Assisted Solution

by:havj123
havj123 earned 250 total points
ID: 24094457
In the HEAD section of the ASP.NET page (.aspx) define the title as a server side control:

... and in the code-behind (.aspx.vb) or inline code, define ...

Protected PageTitle As New HtmlGenericControl

... and set the title from anywhere in the code as ...

Me.PageTitle.InnerText = "Hello World"
0
 
LVL 7

Author Comment

by:TransBind
ID: 24103144
the reason it was creating extra white space / new line characters is because i had <head runat="server">
when i changed it to just <head> .net stopped appending white space / new line to a title. In fact it doesn't really matter how you set your title, even if it is as simple as
<head runat="server"><title>some title</title></head>
this will create white space / new line characters but if u do
<head><title>some title</title></head> it will be fine ...

0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question