473,785 Members | 2,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to set Link tag for style sheet in base page

I've build a basepage that will be used for all the pages in my website. I
created a propery in the base page called Title like this:

Private baseTitle As HtmlGenericCont rol
Protected Property Title() As String
Get
Return baseTitle.Inner Text
End Get
Set(ByVal Value As String)
baseTitle.Inner Text = Value
End Set
End Property

and it sets it's value in an htmlcontrol like this:

' Page Title
baseTitle = New HtmlGenericCont rol("title")
baseTitle.ID = "baseTitle"
Me.Controls.Add (baseTitle)
This way I can set the page title from the page that inherits the base page.
how can I do a similar thing to set the page's stilesheet in the link tag?

I will also be wanting to reference the script files the same way.

Any good recomendations?

--
mo*******@nospa m.com

Nov 18 '05 #1
4 1666
Hi Moondaddy,

From your description, what you want to do is modify the <head> area of the
ASP.NET web page at runtime via code, yes?

As for this problem, currently we haven't any buildin means to do so. Based
on my research, most ones make use of the Literal control to represent the
<head> area of an asp.net web page.
set the
<head runat="server" id="xxx" >
and then use a LiteralControl in code behind to reference it. Also, if you
want to perform a common framework on handling a group of pages. We still
need to integrate this skill together with the PageControler(b ase page)
pattern. And below are some certain web resources discussing on the
similiar problem:

#ASP.NET Page Templates - Using Inheritance
http://www.codeproject.com/aspnet/page_templates.asp

#Dynamically Adding <HEAD> Content with ASP.NET
http://dotnetjunkies.com/WebLog/bsbl...2/11/7052.aspx

An improvement to RegisterClientS criptBlock
http://www.codeproject.com/aspnet/sc...asp?print=true

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #2
Thanks but these just aren't helping me. I've already gone over
http://www.codeproject.com/aspnet/page_templates.asp numerous times and the
others are about the same. for one thing, they're all in c# and although I
can understand the concepts, making it a reality in vb.net is another thing.
even if I use the translation tool you recommended doesn't help much as it
often makes mistakes which ends up consuming lots of time to (try) to fix,
and makes things more confusing. All of this aside, my biggest problem is
one KEY thing. I understand how to use the literalcontrol to create the
html, header, etc... tags. BUT, how do I pass a value into a property from
the derived page and use this property to customize the header tag? These
tags get created when the pages are initialized which happens before I can
pass in a value from the derived class (as far as I know...). This is my
missing link Can you clearify this for me?

Thanks again!

--
mo*******@nospa m.com
"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:aH******** *****@cpmsftngx a10.phx.gbl...
Hi Moondaddy,

From your description, what you want to do is modify the <head> area of the ASP.NET web page at runtime via code, yes?

As for this problem, currently we haven't any buildin means to do so. Based on my research, most ones make use of the Literal control to represent the
<head> area of an asp.net web page.
set the
<head runat="server" id="xxx" >
and then use a LiteralControl in code behind to reference it. Also, if you want to perform a common framework on handling a group of pages. We still
need to integrate this skill together with the PageControler(b ase page)
pattern. And below are some certain web resources discussing on the
similiar problem:

#ASP.NET Page Templates - Using Inheritance
http://www.codeproject.com/aspnet/page_templates.asp

#Dynamically Adding <HEAD> Content with ASP.NET
http://dotnetjunkies.com/WebLog/bsbl...2/11/7052.aspx

An improvement to RegisterClientS criptBlock
http://www.codeproject.com/aspnet/sc...asp?print=true

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3
I found it. It never fails. I make a post like this and then I find it
myself. I was able to get the overall mechanics from the links provided in
the above posts. The way to pass in custom property values to be used in
the header tag creation when the page is initialized is in the derived page
like this:

Protected Overrides Sub OnInit(ByVal e As System.EventArg s)
KeyWords = "Photo Charms, Italian Charms, Mother's Day"
Description = "Best Darn Links Around"
Title = "Hello World"
Link = "<LINK href='Styles/Main.css' type='text/css'
rel='stylesheet '/>"
End Sub

This in WebForm1.aspx which inherits from BasePage.aspx. The properties
KeyWords, Description, Title and Link are used in BasePage to set the header
tag as links in this thread show. The KEY point here is that "OnInit" in
WebForm1.aspx fires before anything else including "OnInit" in BasePage
which allows me to pass in all the custom values I want to use for
initializing BasePage.
--
mo*******@nospa m.com
"moondaddy" <mo*******@nosp am.com> wrote in message
news:e6******** ******@tk2msftn gp13.phx.gbl...
Thanks but these just aren't helping me. I've already gone over
http://www.codeproject.com/aspnet/page_templates.asp numerous times and the others are about the same. for one thing, they're all in c# and although I can understand the concepts, making it a reality in vb.net is another thing. even if I use the translation tool you recommended doesn't help much as it
often makes mistakes which ends up consuming lots of time to (try) to fix,
and makes things more confusing. All of this aside, my biggest problem is
one KEY thing. I understand how to use the literalcontrol to create the
html, header, etc... tags. BUT, how do I pass a value into a property from the derived page and use this property to customize the header tag? These
tags get created when the pages are initialized which happens before I can
pass in a value from the derived class (as far as I know...). This is my
missing link Can you clearify this for me?

Thanks again!

--
mo*******@nospa m.com
"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:aH******** *****@cpmsftngx a10.phx.gbl...
Hi Moondaddy,

From your description, what you want to do is modify the <head> area of

the
ASP.NET web page at runtime via code, yes?

As for this problem, currently we haven't any buildin means to do so.

Based
on my research, most ones make use of the Literal control to represent the <head> area of an asp.net web page.
set the
<head runat="server" id="xxx" >
and then use a LiteralControl in code behind to reference it. Also, if

you
want to perform a common framework on handling a group of pages. We still need to integrate this skill together with the PageControler(b ase page)
pattern. And below are some certain web resources discussing on the
similiar problem:

#ASP.NET Page Templates - Using Inheritance
http://www.codeproject.com/aspnet/page_templates.asp

#Dynamically Adding <HEAD> Content with ASP.NET
http://dotnetjunkies.com/WebLog/bsbl...2/11/7052.aspx

An improvement to RegisterClientS criptBlock
http://www.codeproject.com/aspnet/sc...asp?print=true

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx


Nov 18 '05 #4
Hi Moondaddy,

Thanks for your followup. I'm glad that you've finally figured out the
problem. Also, I think it'll be nice if you would share some of your
solution maybe a demo page here so that some other ones who have the same
problem maybe easy to find the resources here. Do you think so? Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #5

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

Similar topics

5
2530
by: Dave Mausner | last post by:
the html 4.01 standard says i can use: <link type="text/css" href=file-name> to include a style section. questions: 1. does the external style sheet have to contain <html> ... </html>? 2. does it have to contain <style> ... </style>? 3. is <link> recognized within html page <style>? 4. is the <link href> a relative url, i.e., just a file name, or must it be fully qualified?
0
5677
by: Andrea | last post by:
Hi everyone. I'm working on a navigation menu (in a frameset) that I want to set the "active" link to black (the link that corresponds to the page displayed in the right side of the frame) to black. http://www.personal.psu.edu/axg251/wc In the original external style sheet, I set the a:link, a:visited, a:active, and a:hover. That works fine. In the navigation page, I call a function for onclick - it sets the
5
2700
by: Janet | last post by:
The following html code appears in an ASP page. The hyperlink is set to white (see the page link color), but when the page renders in IE 6.0, it initially appears in maroon with a white border around it. When the user clicks anywhere on the page, it turns white. Does anybody know how I can make it appear white when the page first renders? Response.Write("<html><body bgcolor=""#000000"" link=""#FFFFFF"" vlink=""#FFFFFF"">")
2
1155
by: Wade Beasley | last post by:
I have a web site I am working on for a client using ASP.NET with VB.Net for the language. The client decided they needed the ability to choose between different page layouts based on a setting in the database. I have the header and footer working correctly by using a custom base page and before the Page_Load loading the correct version from a subdirectory with the Layout Number as the directory name. Now what I need is the ability to...
2
7027
by: SR | last post by:
I have started a web site using ASP.NET 2.0. I would like to centralize all of my classes in a StyleSheet but I cannot figure out how to link the StyleSheet to a Content Page since there is no header. I tried to put the link tag in the Master page, but the classes are not recognized in the Content Page. How do I use a StyleSheet with the Content Page? TIA
4
7343
by: news.internode.on.net | last post by:
Is there any way that a STYLE attribute can be used to control the color of hyperlinks. We have a tabular output generator written in C#. Each column of the table is defined by a column, and each column can have what is called a "styler". The styler is evaluated once for each cell, for every row emitted. The idea behind the styler is that it can dynamically make decisions on colors to apply. For example a list of Actions could change...
2
1963
by: David W | last post by:
I need to include a style sheet link in the aspx page based on what user they are. Basically this functionality, but using code behind. Any idea how to change this line to code behind? This breaks once we include an AJAX control on the page. <head runat="server"> <link href="/textfiles/style<%= Session("partner_id") %>.css" rel="stylesheet" type="text/css">
14
2024
by: Daniel Kaplan | last post by:
So my style sheet has many different types of LINK styles. And they all work fine on IE, even different styles on the same page. But in Firefox, all link throughout my site all follow JUST the first link class on any page. Any thoughts? As a side thought, in my style sheet I changed what I guess was the "Default" link style (as seen below). Was I wrong in doing that?
4
5635
Frinavale
by: Frinavale | last post by:
So a while ago I created a Tab Strip Control (before the AjaxToolkit had theirs otherwise I would have probably just used theirs). When I looked at the AjaxToolkit control to see how they got around this problem I discovered that they're using Animations. I don't want to bloat my control with the Ajaxtoolkit's Animation stuff though. I guess I should tell you what the problem is. I have a TabStrip custom control. It's a Table that has...
0
9645
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
10341
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...
1
10095
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
9954
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
6741
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
5383
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...
1
4054
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
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
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.