Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

response.write title of the page

Posted on 2009-04-07
5
Medium Priority
?
338 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 1000 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 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

670 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