ASP.NET meta head

  • Thread starter Thread starter GTi
  • Start date Start date
G

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.
 
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
 
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/
 
Back
Top