473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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
Nov 18 '05 #1
2 1996
Hello Amir,
"Amir Eshterayeh" <ae*********@hotmail.com> schrieb im Newsbeitrag
news:ep**************@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.
Nov 18 '05 #2
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" <ae*********@hotmail.com> wrote in message
news:ep**************@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

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Francesco Moi | last post by:
Hello. I'm trying to build a RSS feed for my website. It starts: ----------------//--------------------- <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE rss PUBLIC "-//Netscape...
2
by: Amir Eshterayeh | last post by:
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">...
2
by: brw | last post by:
Is there a way to dynamically add a link tag to the head block of an ..aspx page? I'm aware that you can add a link tag (or literal control) statically and then dynamically modify the attributes....
0
by: Joel Leong | last post by:
In <IMG> tag, we can dynamically specifies the src attribute by using a tilde (~) eg. ~/common/img/picture1.jpg How about this: <LINK href="common/css/common.css" type="text/css"...
1
by: Baldoni | last post by:
It's been years since putting together a page. This line in my HTML: <link type="text/css" rel="stylesheet" href="net4801style.css"> gives this problem (via weblint HTML checker): attribute...
6
by: Spartanicus | last post by:
I'd like to execute a function when a <link rel="next" href="foo.htm"> type element is used. Although the "onclick" handler is allowed on the element, presumably because the functionality of the...
6
exoskeleton
by: exoskeleton | last post by:
hi dear experts...i dont know if im in the right forum but...if not please kindly move this thread.. my problem is that how to change value like this one: <script language="JavaScript"...
2
by: adamjw3 | last post by:
hi guys please help this is well urgent and doing my head in i want to change the href of an <a> tag to that of an image so they are both the same. <script language="JavaScript"...
1
by: ppioter | last post by:
hi this regards asp.net 1.1 I have following problem I would like to change attribute of <LINKtag via ASP I have this definition inside <HEADsection of my aspx file <LINK id="stylesheet"...
3
by: etabetapi | last post by:
I'm trying to build a simple gallery using some thumbnail images to load larger images and SWF files by swapping out the source hrefs. It works okay with images, but I'm having trouble doing the same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.