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. Advertisements

  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. Advertisements

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. Axel Dahmen
    Replies:
    1
    Views:
    826
    Teemu Keiski
    Nov 12, 2003
  2. Oleg Ogurok

    Re: Web User Controls And StyleSheets

    Oleg Ogurok, Jun 30, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    695
    Steven Cheng[MSFT]
    Jul 8, 2004
  3. Logan
    Replies:
    2
    Views:
    495
    Dave Fancher
    Feb 1, 2005
  4. Nathan Sokalski
    Replies:
    5
    Views:
    1,304
    Gaurav Vaish \(www.Edujini-Labs.com\)
    Jan 10, 2007
  5. Faizan Ahmed
    Replies:
    1
    Views:
    503
    John Saunders
    Jan 4, 2005
  6. Nathan Sokalski
    Replies:
    4
    Views:
    553
    Nathan Sokalski
    Dec 21, 2006
  7. Faizan Ahmed
    Replies:
    1
    Views:
    534
    John Saunders
    Jan 4, 2005
  8. Nathan Sokalski
    Replies:
    4
    Views:
    588
    Nathan Sokalski
    Dec 21, 2006
Loading...