How to put <style> in content page

A

ad

I use vs2005 to develop web application.
I have used the new feature of master page of VS2005, and I have put some
<style> in the master page.
But I want to override some Style sheet in the content page.
Where to put the <style> in the content page ?
 
G

Guest

I don't think you can because the content place holder puts eveything within
div tags. Try a different aproach, try using css classes to define your
styles, you can then apply them to the relevent tags wherever you want, using
code.
 
M

Matt Sollars

Try one of the following in your page's Load event handler.

// Add a style sheet link.
HtmlGenericControl Style = new HtmlGenericControl();
Style.Attributes.Add("type", "text/css");
Style.Attributes.Add("rel", "stylesheet");
Style.Attributes.Add("href", "MyStyle.css");
Header.Controls.Add(Style);

// Add inline style.
HtmlGenericControl Style = new HtmlGenericControl();
Style.InnerText = "h1 { color: #0F0; } .MySelector { background-color:
#F90; }";
Header.Controls.Add(Style);


Good luck!

- Matt


----- Original Message -----
From: ad
Date: 8/4/2006 2:29 AM
 
Joined
Nov 1, 2006
Messages
3
Reaction score
0
Where to put the <style> in the content page ?

Hi Matt Sollars,

Where we can put this code? In the content page load event or Master page load event?
I tried it with content page load event.
but still my styles have not applied to the my data grid.
I have a data grid control in one of my content place holder page.
I have a theme style sheet in "../App_Themes/mystyles.css"


I put this code...but can u help me out

// Add a style sheet link.
HtmlGenericControl Style = new HtmlGenericControl();
Style.Attributes.Add("type", "text/css");
Style.Attributes.Add("rel", "stylesheet");
Style.Attributes.Add("href", "../App_Themes/company/mystyles.css");
Header.Controls.Add(Style);

I have some styles for my data grid in this css clas. how can I make it?

pls help

Matt Sollars said:
Try one of the following in your page's Load event handler.

// Add a style sheet link.
HtmlGenericControl Style = new HtmlGenericControl();
Style.Attributes.Add("type", "text/css");
Style.Attributes.Add("rel", "stylesheet");
Style.Attributes.Add("href", "MyStyle.css");
Header.Controls.Add(Style);

// Add inline style.
HtmlGenericControl Style = new HtmlGenericControl();
Style.InnerText = "h1 { color: #0F0; } .MySelector { background-color:
#F90; }";
Header.Controls.Add(Style);


Good luck!

- Matt


----- Original Message -----
From: ad
Date: 8/4/2006 2:29 AM
> I use vs2005 to develop web application.
> I have used the new feature of master page of VS2005, and I have put some
> <style> in the master page.
> But I want to override some Style sheet in the content page.
> Where to put the <style> in the content page ?
>
>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top