Specify Image location in Web.Config

  • Thread starter Thread starter Manny Chohan
  • Start date Start date
M

Manny Chohan

Hello Guys,

Just curious over the fact if i can store Image Location in Web.Config and
then how can i extract that location in HTML

<td style="width:1%" align="left" valign="middle">
<img alt="" src="<%# image Location'
%>/Images/lhw_logo_black.jpg" id=headerImage runat=server /></td>
<td style="width: 1%" align="right" valign="middle">

Is it possible to do something like this or not? I am developing in C#2.0 .
I am trying to avoid this in Codebehind.

Thanks

Manny
 
just create a function in you base page like ImagePath(string s) then you can
use it in a binding expression (which will require a bind) or standand.

<img src='<%# ImagePath("myImage.gif")%>' runat="server"/>
<img src='<%= ImagePath("myImage.gif")%>' />

another option is a prerender handler that walks the control collection
(requires each image have a runat=server). and update the src.


-- bruce (sqlwork.com)
 
in Page ASPX:
<asp:Image ID="Image1" runat=server ImageUrl = '<%$ appSettings:myImage1
%>' />

in web.config:

<appSettings >
<add key="myImage1" value="~/images/check2.gif"/>
</appSettings>

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: htp://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net
 
Thanks Bruce. How about if the ImagePath is located in a Class file under
your App_Code folder?
 
sure, just make it a public static, but its a good practice to have a base
page, that your pages inherit from.


-- bruce (sqlwork.com)
 
Thanks. It works.

bruce barker said:
sure, just make it a public static, but its a good practice to have a base
page, that your pages inherit from.


-- bruce (sqlwork.com)
 
Thanks Peter. In your example, you have specified the image name in the web
config. can we not do that and instead have the Web.Config return base
location of the image i.e http://servername/appname/images

and in HTML:
<asp:Image ID="Image1" runat=server ImageUrl = '<%$ appSettings:myImage1
%>/imagename.jpg' />

I have tried various combos and they didnt work. Can you please assist?

Thanks

Manny
 
Back
Top