Solved

response.write title of the page

Posted on 2009-04-07
5
323 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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