Stylesheets on web user controls

Discussion in 'ASP .Net Web Controls' started by Larry, Dec 11, 2003.

  1. Larry

    Larry Guest

    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
     
    Larry, Dec 11, 2003
    #1
    1. Advertising

  2. 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.
     
    Jeffrey Tan[MSFT], Dec 12, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael Mckenzie

    Re: user control stylesheets

    Michael Mckenzie, Apr 22, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    409
    Michael Mckenzie
    Apr 22, 2004
  2. Oleg Ogurok

    Re: Web User Controls And StyleSheets

    Oleg Ogurok, Jun 30, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    559
    Steven Cheng[MSFT]
    Jul 8, 2004
  3. Logan
    Replies:
    2
    Views:
    351
    Dave Fancher
    Feb 1, 2005
  4. BJF

    External stylesheets and custom controls

    BJF, Jun 28, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    124
  5. Thomas 'PointedEars' Lahn
    Replies:
    0
    Views:
    129
    Thomas 'PointedEars' Lahn
    May 1, 2004
Loading...

Share This Page