Cleaning Up Image Paths.

Last post 12-11-2006 6:29 AM by gsuttie2002. 8 replies.

Sort Posts:

  • Cleaning Up Image Paths.

    12-02-2006, 7:15 PM
    • Member
      42 point Member
    • meinmk5
    • Member since 12-03-2006, 12:10 AM
    • Posts 44

    Hello.

    At this stage in my project I am trying to clean up the code by resorting the imageUrl's back to the web.config which contains the images path.

    I have tried a few ways with no success... What would be the proper entry into the web.config be to do this?

    MCPD
  • Re: Cleaning Up Image Paths.

    12-04-2006, 6:38 AM
    • Contributor
      2,716 point Contributor
    • gsuttie2002
    • Member since 09-07-2002, 10:17 AM
    • Scotland, UK
    • Posts 578

    HI Meinmk5

    I usually create an Images folder to start wit and plonk them in there and then take a look at this article where RIck discusses  Relacive Paths

    http://west-wind.com/weblog/posts/269.aspx

    I'm not in favour of hard coding url imge url's into the web.config because if you need the same image in two seperate places your copying the code and then modifying it for the same image.

    Anyway if you want to go for the web.config route try this.

    <add key="homepageicon" value="~/images/homeicon.gif"/>

    Then you just read the value of homepageicon using the congiuration manager - along those lines.

    Give me a shout if that doesnt help.

    Gregor Suttie
    MCSD, MCAD, MCSD.Net
  • Re: Cleaning Up Image Paths.

    12-07-2006, 4:11 PM
    • Member
      42 point Member
    • meinmk5
    • Member since 12-03-2006, 12:10 AM
    • Posts 44

    The site I am building will be using the same images multiple times.

    This is for parts of the page that will be concrete.

    Could I do the same thing for text? Like if I am going to use the same description a bunch of times could I insert something into the web.config to have one key to refer to?

     

    MCPD
  • Re: Cleaning Up Image Paths.

    12-07-2006, 4:17 PM
    • Contributor
      2,716 point Contributor
    • gsuttie2002
    • Member since 09-07-2002, 10:17 AM
    • Scotland, UK
    • Posts 578

    Hi again

    If the content is static (doesnt change) make sure you cash it - you could add it to a user control and cash the user control.

    Cheers
    Gregor 

    Gregor Suttie
    MCSD, MCAD, MCSD.Net
  • Re: Cleaning Up Image Paths.

    12-07-2006, 4:25 PM
    • Member
      42 point Member
    • meinmk5
    • Member since 12-03-2006, 12:10 AM
    • Posts 44

    Sorry, I'm a ASP novice at best.... Need a little bit more detail about using a user control.

     

    MCPD
  • Re: Cleaning Up Image Paths.

    12-08-2006, 11:16 AM
    • Member
      42 point Member
    • meinmk5
    • Member since 12-03-2006, 12:10 AM
    • Posts 44

    Below are the errors I get when I use the <add> statement in my web.config.

    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

    Parser Error Message: Unrecognized configuration section 'add'

    Source Error:

    Line 4:    <system.web>
    Line 5:  <add key="mainLink" value="Main"/>

     Is there a particular section I need to establish in the web.config? I tried inserting the line in multiple spots in the file and all returned errors.



    MCPD
  • Re: Cleaning Up Image Paths.

    12-08-2006, 4:47 PM
    • Contributor
      2,716 point Contributor
    • gsuttie2002
    • Member since 09-07-2002, 10:17 AM
    • Scotland, UK
    • Posts 578

    Hi There

     <appSettings>
    <add key="mainLink" value="Main"/>

    <appSettings/>

    Try that

     

    Gregor Suttie
    MCSD, MCAD, MCSD.Net
  • Re: Cleaning Up Image Paths.

    12-10-2006, 8:23 PM
    • Member
      42 point Member
    • meinmk5
    • Member since 12-03-2006, 12:10 AM
    • Posts 44

    Well the web.config compiles fine but now the page itself will not pickup the call in the web.config.

     

    I tried both formats in the web.config

     <add key="mainLink" value="Main"/>
    <add key="mainLink" text="Main"/>

    and

     <asp: hyperlink id="mainLink"

    and

    <asp: hyperlink id="mainLink" value/text="mainLink"

    Any ideas?

    P.S. I greatly appreciate the assistance up to this point :) 

     

    MCPD
  • Re: Cleaning Up Image Paths.

    12-11-2006, 6:29 AM
    Answer
    • Contributor
      2,716 point Contributor
    • gsuttie2002
    • Member since 09-07-2002, 10:17 AM
    • Scotland, UK
    • Posts 578

    Hi Dude

    Ok try this

    web.config:-

    <appSettings>
    <add key="mainLink" value="Main"/>
    <
    appSettings/>

    Add a reference (using Statement) to System.Configuration at the top of the page and then on the front end you need your

    <asp: hyperlink id="hyperlink1" runat="server" />

    Read more here :- http://aspnet.4guysfromrolla.com/articles/053102-1.aspx

    Cheers
    Gregor

    Gregor Suttie
    MCSD, MCAD, MCSD.Net
Page 1 of 1 (9 items)