Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Change <link> href attribute dynamically

Reply
Thread Tools

Change <link> href attribute dynamically

 
 
Simon Gorski
Guest
Posts: n/a
 
      03-06-2004
Hello Amir,
"Amir Eshterayeh" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> 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.


 
Reply With Quote
 
 
 
 
Manohar Kamath [MVP]
Guest
Posts: n/a
 
      03-06-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Amir Eshterayeh
Guest
Posts: n/a
 
      03-06-2004
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
href="javascript:func()" vs href="#" onclick="javascript:func()" CRON HTML 24 06-20-2006 08:05 PM
onClick method question (this.href and document.location.href) yogesh.bhardwaj@gmail.com Javascript 2 02-03-2005 02:38 PM
difference between location.href and window.location.href? saiho.yuen Javascript 3 09-14-2004 06:51 PM
Change <link> href attribute dynamically Simon Gorski ASP .Net Building Controls 2 03-06-2004 08:04 PM
Problem: Setting MSIE iframe innerHTML change relative href/src to absolute href/src Soren Vejrum Javascript 4 07-05-2003 01:47 PM



Advertisments