Stylesheets on web user controls

L

Larry

If I put a web control within a web user control, and
this web control depends on a CSS for some settings, then
do I simply embed a
<LINK href="style.css" type="text/css" rel="stylesheet">
statement within the *.ascx file? I ask because doing so
doesn't seem to work and I want to know if there is some
trick.
Thanks
 
J

Jeffrey Tan[MSFT]

Hi Larry,

Thanks for posting in this group.
The style sheet will apply its style on the client html tag, while not the
server side webcontrol.
So you should write your .css file and apply it on the html tag that
generated by the webcontrol.

I think you can do like this(Apply css on asp:HyperLink webcontrol, so you
need apply css on <a> html tag):
First, create a asp.net webform application. Then, add a new item: Style
sheet(.css) and Web User Control(.ascx) to the project.
..css file content:
A
{
cursor:wait;
text-decoration: underline;
}

Add a HyperLink webcontrol in the .ascx, then drag the .css file in
"solution explore" to the designer of Web user control.
In the html view of .ascx, you will see that <LINK href="StyleSheet1.css"
type="text/css" rel="stylesheet"> is added to the user control.

At last, drop .ascx to the .aspx webform, view it. You will see the
stylesheet takes effect.

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

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
474,083
Messages
2,570,591
Members
47,212
Latest member
RobynWiley

Latest Threads

Top