473,385 Members | 1,325 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,385 software developers and data experts.

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 HtmlGenericControl
Protected Property Title() As String
Get
Return baseTitle.InnerText
End Get
Set(ByVal Value As String)
baseTitle.InnerText = Value
End Set
End Property

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

' Page Title
baseTitle = New HtmlGenericControl("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*******@nospam.com

Nov 18 '05 #1
4 1651
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(base 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 RegisterClientScriptBlock
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*******@nospam.com
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:aH*************@cpmsftngxa10.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(base 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 RegisterClientScriptBlock
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.EventArgs)
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*******@nospam.com
"moondaddy" <mo*******@nospam.com> wrote in message
news:e6**************@tk2msftngp13.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*******@nospam.com
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:aH*************@cpmsftngxa10.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(base 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 RegisterClientScriptBlock
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
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...
0
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...
5
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...
2
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...
2
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...
4
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...
2
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...
14
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...
4
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.