473,612 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(sende r As Object, e As EventArgs)
myhead.InnerHtm l &="<LINK href=""Styleson e.css"" type=""text/css""
rel=""styleshee t"">"
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 15 '05 #1
2 4763
Hello Amir,
"Amir Eshterayeh" <ae*********@ho tmail.com> schrieb im Newsbeitrag
news:ep******** ******@TK2MSFTN GP12.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(sende r As Object, e As EventArgs)
myhead.InnerHtm l &="<LINK href=""Styleson e.css"" type=""text/css""
rel=""styleshee t"">"
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.H tmlControls.Htm lControl myhead;

mfg simo g.
Nov 15 '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*********@ho tmail.com> wrote in message
news:ep******** ******@TK2MSFTN GP12.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(sende r As Object, e As EventArgs)
myhead.InnerHtm l &="<LINK href=""Styleson e.css"" type=""text/css""
rel=""styleshee t"">"
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 15 '05 #3

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

Similar topics

9
2952
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 Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd"> <rss version="0.91"> ----------------//----------------------
2
1648
by: Hernán Castelo | last post by:
hi i'm trying to do : <link rel="stylesheet" type="text/css" href="myurl..../inc/css/style.css"/> from the url field of the browser i can normally open the "style.css" with notepad but thru the <link> tag, IIS don't match the file ?? should i add some configuration to run CSS ? i'm using URLScan and have activated the .css extension
2
1807
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. I'm wondering if there's a way to add the tag from scratch at run time. thanks, Ben
2
2006
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"> ...permanent content here... </head> so that I can modify it from code like this: Sub Page_Load(sender As Object, e As EventArgs)
2
1715
by: Gopalan | last post by:
Hi I was using <link href="...." type="..."> tag inside the .aspx file. When I converted this aspx file to ascx file and use it in an aspx file it is not working properly. Please tell me where to put it. Thanks
1
2371
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 'TYPE' for <link> is extended markup (use -x <extension> to do this). Where might be found a resource, for simple folk, explaining how to best correct this?
6
1482
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 element is made available through a browser provided navbar the function doesn't execute when using the element. Anyone know if this is possible? -- Spartanicus
9
6897
by: Arancaytar | last post by:
I have so far seen two methods for including external resources as CSS stylesheets in a document. The first is this: <link href="/stylesheets/style.css" rel="stylesheet" type="text/css" /> And the second is this: <style type="text/css"> @import "/stylesheets/style.css"; </style>
1
1792
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" href="test1.css" type="text/css" rel="stylesheet" > I want it to be changed to following when user checks different theme from
0
8162
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8105
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8605
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8565
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8415
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7039
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5532
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4045
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
1413
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.