471,610 Members | 1,350 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,610 software developers and data experts.

ASP.NET meta head

GTi
When i Use
HtmlHead head.Title
I can change the <title> of a webpage from codebehind.
But I need to add <meta>, <link href=> an <script src=> also from
codebehind.

Nov 29 '05 #1
2 1175
For script blocks u can use Page.RegisterStartupScript.. for link href u may
prefer asp style construction. For instance, MyVariable must be (at least)
protected variable/property...

<link href="<%=MyVariable%>"

But it is not recommended.. Try to remove your dependencies. Codebehind is
to remove this tightly coupled connections between Design and
Implementation...
--
HTH

Thanks,
Yunus Emre ALP÷ZEN
BSc, MCSD.NET

"GTi" <tu****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
When i Use
HtmlHead head.Title
I can change the <title> of a webpage from codebehind.
But I need to add <meta>, <link href=> an <script src=> also from
codebehind.

Nov 29 '05 #2
There's a new HtmlLink class that writes the link element into the head but
there does not appear to be an equivalent for writing a script element into
the head. I'm using this...

#region Write JavaScript <script> Element External File Reference...

// Define an arbitrary but unique name to use as a key
String key = "ExternalJavaScriptReference";
String url = Request.ApplicationPath + "/Scripts/scripts.js";

// Instantiate ClientScript object
ClientScriptManager cs = Page.ClientScript;

// Do not register if this instance of the key is already registered
already.
if (!cs.IsClientScriptIncludeRegistered(key))
{
// Write <script> element into body of the page
cs.RegisterClientScriptInclude(key, url);
}
#endregion

That writes the <script> element into the body and as far as I can tell
provides the same functionality as it were in the head noting I'd like to
know the difference if any.
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/


"Yunus Emre ALP÷ZEN [MCSD.NET]" <yemre> wrote in message
news:Oo***************@TK2MSFTNGP15.phx.gbl...
For script blocks u can use Page.RegisterStartupScript.. for link href u
may prefer asp style construction. For instance, MyVariable must be (at
least) protected variable/property...

<link href="<%=MyVariable%>"

But it is not recommended.. Try to remove your dependencies. Codebehind is
to remove this tightly coupled connections between Design and
Implementation...
--
HTH

Thanks,
Yunus Emre ALP÷ZEN
BSc, MCSD.NET

"GTi" <tu****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
When i Use
HtmlHead head.Title
I can change the <title> of a webpage from codebehind.
But I need to add <meta>, <link href=> an <script src=> also from
codebehind.


Nov 29 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Darren Blackley | last post: by
3 posts views Thread by J1C | last post: by
2 posts views Thread by localhost | last post: by
1 post views Thread by Maziar Aflatoun | last post: by
4 posts views Thread by clintonG | last post: by
6 posts views Thread by Fred Nelson | last post: by
1 post views Thread by joeblast | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.