473,587 Members | 2,509 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using a Stylesheet in a User Control

I have a user control that uses classes from a CSS Stylesheet. Because a
User Control does not have a <head> section, I do not know where to put a
link tag to link it to the stylesheet. If I manually place a a link tag in
the page that I use the User Control in it works fine, but is there a way to
have the control add this link tag for me when I insert the control? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/
Nov 19 '05 #1
2 1821
You can inject the link tag into the page that hosts the user control. You
could place a Literal control on the page, then set its .Text property to a
string containing the the link tag. You could do this at the same place in
your code where you insert the control.

-HTH
"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
I have a user control that uses classes from a CSS Stylesheet. Because a
User Control does not have a <head> section, I do not know where to put a
link tag to link it to the stylesheet. If I manually place a a link tag in
the page that I use the User Control in it works fine, but is there a way
to have the control add this link tag for me when I insert the control?
Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

Nov 19 '05 #2
EJD
Hi,

The user control that I have in one of my projects looks like this in
the HTML:

<%@ Control Language="c#" AutoEventWireup ="false"
Codebehind="Hea der.ascx.cs" Inherits="MyPro ject.Header1"
TargetSchema="h ttp://schemas.microso ft.com/intellisense/ie5"%>
<LINK href="MyProject .css" type="text/css" rel="stylesheet ">

Although I do use the same css file for all of the pages in the
project, if I just add the UC to a blank page without adding it to the
webform as well, it seems to work fine... HTH.
EJD

Nov 19 '05 #3

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

Similar topics

1
3267
by: Eric Anderson | last post by:
I am trying to use XSLT to extend XHTML so that I can have custom widgets. For example I have a calendar control. Whenever I put the following in the psudo-XHTML doc: <calendarbox name="mycal"/> I get a nice xhtml text box with a calendar icon beside it. When the calendar icon is clicked a calender pops up to allow the user to choose the date. Then the value chosen is stuck in the xhtml text field and can be submitted with the form. I...
1
2070
by: Amir Eshterayeh | last post by:
Dear Friends I need to change the css file of my aspx files dynamically so users can choose their css file names and when page loads, it read css file name from database. I try to use response.write to write this way: Dim i As Integer = 1 If i = 1 Then Response.Write("<LINK href=""Stylesone.css"" type=""text/css"" rel=""stylesheet"">") Response.Write("<script language =""javascript"" src = ""testone.js"">
7
1570
by: Nathan Sokalski | last post by:
I have user controls that contain a link to a stylesheet. Several of my pages also have a link to this same stylesheet. Because of this, the resulting output contains multiple links to the same stylesheet. Although this does not cause any harm as far as how the page looks, it is unnecessary and makes the download take slightly longer. Is there any easy way to avoid having the same stylesheet link added multiple times? Thanks. -- Nathan...
1
8782
by: Paul | last post by:
Is there a special way to reference a Stylesheet (.css) in a usercontrol? I have a usercontrol in an aspx page.The aspx page itself has a Header Div, within which I put my UserControl.ascx. In the UserControl I want to use DIVS only, just to make work easier at a future point. So, I have an outer Div called HeaderContainer, and then some contained divs. If this were just an aspx page, then all the rendering is fine, but when I try to do...
15
1767
by: Scott W Gifford | last post by:
Hello, We've got a Web-based application written in Perl that is designed to integrate as a frame into many different Web sites. We currently have several stylesheets available to allow the user to match the look and feel to their existing Web site. We're considering allowing our users to host their own stylesheet, and just pass in its URL as a CGI parameter. Something like this: ...
1
1497
by: mikeh3275 | last post by:
I have a header control that I include in my .aspx page. In this control, I'm trying to retrieve a cookie value and store it into a string, but I am receiving an "Object reference not set to an instance of an object." error. Below is the code. Any help is appreciated. Thanks. .aspx page: <%@ Page Language="C#" AutoEventWireUp=true CodeFile="OrderAdmin.aspx.cs" Inherits="_Default" %> <%@ Reference...
8
8929
by: =?Utf-8?B?Q2hyaXMgSGFsY3Jvdw==?= | last post by:
Hi there I've successfully added some .NET validation controls to a page (using <asp:RequiredFieldValidator ...), however when I try to set the 'display' property to 'dynamic', my page then throws up the following error in the browser: CS1061: 'System.Web.UI.WebControls.TextBox' does not contain a definition for 'Web' and no extension method 'Web' accepting a first argument of type 'System.Web.UI.WebControls.TextBox' could be found...
2
1614
by: Andy B | last post by:
How do you use css in a user control? I need to put the css in a stylesheet outside of the control.
3
1869
by: Dave Angel | last post by:
I have implemented the 'A list apart' styleswitcher which works great. I now have: - A permanent stylesheet - A normal contrast stylesheet - A high contrast stylesheet The switcher simply switches between the normal/high sheets. HOWEVER. I now wish to add a font resizer. It needs to be able to
0
8216
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
8349
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...
1
7974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5395
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
3845
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
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
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.