Solved

response.write title of the page

Posted on 2009-04-07
5
318 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
  • 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

789 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