SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: config variable

  1. #1
    SitePoint Zealot ChestRockwell's Avatar
    Join Date
    Nov 2003
    Location
    New Jersey
    Posts
    195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    config variable

    Hello,
    I am a total .net n00b so sorry if this is a dumb question.

    I am using a masterpage and I need to set up a stylesheet, now, since my masterpages are in one directory and I have my pages in different directories I need to hardcode the path to the stylesheets. I don't really want to hardcode the paths, that is just not a good practice. So, what I want to do is set set a config variable for my path. So, I did this in my web.config:

    Code:
       <appSetting>
          <add key="rootURL" value="http://localhost/mySite/" />
       </appSetting>
    In my masterpage, I wanted to do this:

    Code:
        <head runat="server">
           <title>My Site</title>
             
            <link rel="stylesheet"  href="$appSetting:rootURL/styles/mySite_common.css" media="screen,projection" type="text/css" />
    
        </head>
    Alas, that last little bit of code is not working and I really don't know why. Any ideas what I am doing wrong?

    I don't know if this matters but this is a C# project.
    -- Joe C --
    "Do or do not. There is no try..."
    - Yoda

  2. #2
    SitePoint Zealot ChestRockwell's Avatar
    Join Date
    Nov 2003
    Location
    New Jersey
    Posts
    195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe that didnt make sense, and maybe there is a better way to do this so let me phrase this another way: can i create a global variable, maybe in my masterpage or something, that I can use in the head and body areas as the root of my website

    in pseudo code I would say:
    Code:
    ...somewhere...
    string PATH = "www.site.com";
    
    ...in my <head> area...
    
    
    <html>
       <head>
          <link src="PATH/styles/something.css" />
       </head>
       ...
    -- Joe C --
    "Do or do not. There is no try..."
    - Yoda

  3. #3
    SitePoint Guru Chroniclemaster1's Avatar
    Join Date
    Jun 2007
    Location
    San Diego, CA
    Posts
    784
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I haven't done it this way, however, there is information on specifying paths in ASP.NET that you might find useful...

    http://msdn2.microsoft.com/en-us/library/ms178116.aspx

    that's a good starting point, and you can wander through MSDN from there based on what seems to fit your needs best.
    Whatever you can do or dream you can, begin it.
    Boldness has genius, power and magic in it. Begin it now.

    Chroniclemaster1, Founder of Earth Chronicle
    A Growing History of our Planet, by our Planet, for our Planet.

  4. #4
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,625
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    All you really need to do in that case is:

    Code:
    <link rel="stylesheet" runat="Server" url="~/styles/mySite_common.css" />
    The reason it is not being resolved in your example is you need to use the proper syntax, in this case <&#37; $myvalue %> (IIRC, haven't used it in a while).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •