Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Change <link> href attribute dynamically (http://www.velocityreviews.com/forums/t74862-change-link-href-attribute-dynamically.html)

Simon Gorski 03-06-2004 06:05 PM

Re: Change <link> href attribute dynamically
 
Hello Amir,
"Amir Eshterayeh" <aeshterayeh@hotmail.com> schrieb im Newsbeitrag
news:epFJJx5AEHA.2632@TK2MSFTNGP12.phx.gbl...
> Dear Friends
> I want to change the name of my css file dynamically so
> as Mr. Jos Branders helped me, I can change the <head> tag into an HTML
> control like this:
> <head id="myhead" runat="server">
> ...permanent content here...
> </head>
> so that I can modify it from code like this:
>
> Sub Page_Load(sender As Object, e As EventArgs)
> myhead.InnerHtml &="<LINK href=""Stylesone.css"" type=""text/css""
> rel=""stylesheet"">"
> End Sub
>
> But when I run the code, I got this error:
> The type or namespace name 'myhead' could not be found (are you missing a
> using directive or an assembly reference?)


I'd use a literalControl:
<head>
<asp:Literal id="styles" runat="server"></asp:Literal>
</head>

Or a protected variable:
Dim Protected _styleSheet As String
_styleSheet = "<LINK href=Stylesone.css type=text/css>"

<head>
<%= styleSheet %>
</head>

> But when I run the code, I got this error:
> The type or namespace name 'myhead' could not be found (are you missing a
> using directive or an assembly reference?)

You have to declare the myhead in the code-behind:
protected System.Web.UI.HtmlControls.HtmlControl myhead;



mfg simo g.



Manohar Kamath [MVP] 03-06-2004 06:13 PM

Re: Change <link> href attribute dynamically
 
LINK is not really a property of the Page class. One thing you can do is, to
use template approach -- change the LINK dynamically in the template
control.

http://www.codeproject.com/aspnet/page_templates.asp


--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com


"Amir Eshterayeh" <aeshterayeh@hotmail.com> wrote in message
news:epFJJx5AEHA.2632@TK2MSFTNGP12.phx.gbl...
> Dear Friends
> I want to change the name of my css file dynamically so
> as Mr. Jos Branders helped me, I can change the <head> tag into an HTML
> control like this:
> <head id="myhead" runat="server">
> ...permanent content here...
> </head>
> so that I can modify it from code like this:
>
> Sub Page_Load(sender As Object, e As EventArgs)
> myhead.InnerHtml &="<LINK href=""Stylesone.css"" type=""text/css""
> rel=""stylesheet"">"
> End Sub
>
> But when I run the code, I got this error:
> The type or namespace name 'myhead' could not be found (are you missing a
> using directive or an assembly reference?)
>
> Please help.
>
> Thanks in advance. Andy
>
>




Amir Eshterayeh 03-06-2004 08:04 PM

Change <link> href attribute dynamically
 
Dear Friends
I want to change the name of my css file dynamically so
as Mr. Jos Branders helped me, I can change the <head> tag into an HTML
control like this:
<head id="myhead" runat="server">
...permanent content here...
</head>
so that I can modify it from code like this:

Sub Page_Load(sender As Object, e As EventArgs)
myhead.InnerHtml &="<LINK href=""Stylesone.css"" type=""text/css""
rel=""stylesheet"">"
End Sub

But when I run the code, I got this error:
The type or namespace name 'myhead' could not be found (are you missing a
using directive or an assembly reference?)

Please help.

Thanks in advance. Andy




All times are GMT. The time now is 08:59 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.