Solved

response.write title of the page

Posted on 2009-04-07
5
295 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now