Global Stylesheet

Discussion in 'ASP .Net' started by Michael Rich, Apr 7, 2005.

  1. Michael Rich

    Michael Rich Guest

    Is there a way to apply a single stylesheet to all pages in a
    project (vb)?

    Michael Rich, Apr 7, 2005
    1. Advertisements

  2. Michael Rich

    bijoy Guest

    Yes. Save it on your webserver and link to it from all your pages.

    For eg. <LINK href="mystylesheet.css" type="text/css" rel="stylesheet">
    bijoy, Apr 7, 2005
    1. Advertisements

  3. Michael Rich

    Matt Berther Guest

    Hello Michael,

    Well, in all but the most trivial cases, you will likely have a base class
    that all of your pages derive from. Add some code to register

    <link href="mystylesheet.css" type="text/css" rel="stylesheet">

    and it will be applied to any page you derive from. You might want to look
    at Page.RegisterClientScriptBlock [1] for this. The name implies that it
    should be only used with <script> tags, but this will work with any tag that
    needs to insure that there is only one instance of the tag on the page.

    This is typically much easier than adding the declaration to each page.

    Matt Berther, Apr 7, 2005
  4. Michael Rich

    Aquila Deus Guest

    In 2.0 there will be Master Page, which acts as a template for all
    pages, and allows you to put common UI part there.

    In v1, however, you can code the template by yourself, see

    The key is to bind all controls in template to their page classes using
    reflection, because controls created in templates are not assigned
    automatically to their corresponding fields in the page class. This
    requires a lot of changes though.
    Aquila Deus, Apr 7, 2005
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.