Write & Format Meta Tags?

J

John Horst

Porbably the easiest way would be to add this in the <head></head>
section:

<asp:Literal runat="server" id="metaPlaceHolder"></asp:Literal>

Then in Page_Load you would iterate through whatever dynamic source you
have for your meta tag info and add the html line by line:

this.metaPlaceHolder.Text = "<meta name=\"keywords\" content=\"one, two,
three\">\n";


-----Original Message-----
From: clintonG [mailto:[email protected]]
Posted At: Wednesday, August 31, 2005 11:52 AM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: Write & Format Meta Tags?
Subject: Write & Format Meta Tags?


Anybody know how to dynamically write the meta tags using code so they
are formatted on a separate line in the HTML source?
Preferred or optimal framework classes that may be used in this regard?

<meta... />
<meta... />
<meta... />


<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
 
J

John Horst

My last was missing something...

Probably the easiest way would be to add this in the <head></head>
section:

<asp:Literal runat="server" id="metaPlaceHolder"></asp:Literal>

Then in Page_Load you would iterate through whatever dynamic source you
have for your meta tag info and add the html line by line:

this.metaPlaceHolder.Text = "<meta name=\"keywords\" content=\"one, two,
three\">\n\t\t";
this.metaPlaceHolder.Text += "<meta name=\"keywords\" content=\"one,
two, three\">";

The /n add the CrLf and the /t/t adds two tabs to line the tags up.

John

-----Original Message-----
From: clintonG [mailto:[email protected]]
Posted At: Wednesday, August 31, 2005 11:52 AM Posted To:
microsoft.public.dotnet.framework.aspnet
Conversation: Write & Format Meta Tags?
Subject: Write & Format Meta Tags?


Anybody know how to dynamically write the meta tags using code so they
are formatted on a separate line in the HTML source?
Preferred or optimal framework classes that may be used in this regard?

<meta... />
<meta... />
<meta... />


<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
 
C

clintonG

Thanks Curt and John. Consider this...

// HtmlMeta Class [1],[2]
HtmlMeta meta = new HtmlMeta();
meta.Attributes.Add("description", "blah blah blah");
HtmlHead head = (HtmlHead)Page.Header;
head.Controls.Add(meta);

But using that class concatentates the text in the HTML source. You'd think
the persons who wrote that class would have at least considered doing it
right because I haven't determined a trick to work-around yet and it looks
like if we want readable results we will have to resort to the use of a
control in the head element.

<%= Clinton Gallagher

[1] http://msdn2.microsoft.com/library/ms154704(en-us,vs.80).aspx
[2] http://www.howtoadvice.com/SetMetaTags
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top