Sure, that code snippet works fine Ken but the context of the head element
is much broader than a snippet infers so I thought I'd throw in the big
picture in case the OP is a serious developer who may be currently ignorant
but wants to learn how to master the framework. Once finding and loading the
documentation for a class such as the HtmlHead class the menu for MSDN
documentation will also display all the related classes such as HtmlLink,
HtmlMeta and so on. Very insightful wouldn't you agree?
As you may recall, one of the most frequently asked questions used to be
"[should I | how do I] do this using my own code or is there a class already
built in the framework?" That was early in the days when those who really
wanted to learn to be masterful were interested in delving into the
framework.
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL
http://clintongallagher.metromilwaukee.com/
MAP 43°2'17"N 88°2'37"W : 43°2'17"N 88°2'37"W
"Ken Cox [Microsoft MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Mine doesn't work?
>
> "clintonG" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Check out the new classes related to the head element buy using this
>> search term...
>>
>> HtmlHead class site:msdn2.microsoft.com
>>
>> <%= Clinton Gallagher
>> NET csgallagher AT metromilwaukee.com
>> URL http://clintongallagher.metromilwaukee.com/
>> MAP 43°2'17"N 88°2'37"W : 43°2'17"N 88°2'37"W
>>
>> "Ken Cox [Microsoft MVP]" <(E-Mail Removed)> wrote in
>> message news:(E-Mail Removed)...
>>> Hi Ganesh,
>>>
>>> Here's some code that creates a style in code at runtime.
>>>
>>> Let us know if this helps?
>>>
>>> Ken
>>> Microsoft MVP [ASP.NET]
>>>
>>> <%@ Page Language="VB" %>
>>>
>>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>>>
>>> <script runat="server">
>>>
>>> Protected Sub Page_Load _
>>> (ByVal sender As Object, _
>>> ByVal e As System.EventArgs)
>>> ' Instantiate a style object
>>> Dim styl As New Style
>>> ' Set the style (e.g., background colour)
>>> styl.BackColor = Drawing.Color.Aqua
>>> ' Assign the style, URL [nothing here] and selector
>>> Page.Header.StyleSheet.CreateStyleRule _
>>> (styl, Nothing, ".MyClass")
>>> End Sub
>>> </script>
>>>
>>> <html xmlns="http://www.w3.org/1999/xhtml" >
>>> <head id="header1" runat="server">
>>> <title>Creating a style at runtime</title>
>>> </head>
>>> <body>
>>> <form id="form1" runat="server">
>>> <div>
>>> <asp:label cssclass="MyClass" id="Label1" runat="server"
>>> text="Style created in code"></asp:label></div>
>>> </form>
>>> </body>
>>> </html>
>>>
>>>
>>> "Ganesh Muthuvelu" <(E-Mail Removed)> wrote in
>>> message news:37C54983-F66A-4441-86B6-(E-Mail Removed)...
>>>> Hello,
>>>> I am a ASPX page where I have defined the style for the head element.
>>>> ******************
>>>> <head runat="server" >
>>>> <style type="text/css">
>>>> .MyClass
>>>> {
>>>> background-color: aqua;
>>>> }
>>>> </style>
>>>> </head>
>>>> ******************
>>>>
>>>> However, instead of doing at design time, I need to do this at run
>>>> time..
>>>> Can someone help how to add this @ run time to the page?.
>>>>
>>>> Thanks,
>>>> Ganesh
>>>
>>>
>>
>>
>
>