Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

I am facing some problem, any body help me please.
My problem is - I am use a image button , a app key define in my web config

and i am access in my aspx page as like below mentioned and concatenate my image name but it is didn't show.

My web config code is

XML
<appSettings>
  <add key="PagePath"  value="http://localhost:3007/"/><pre>  </appSettings>



and my page code is

XML
<asp:ImageButton ID="imgUpdate" runat="server" ImageUrl='<%$ AppSettings:PagePath %>_Images/btn-edit.jpg' CausesValidation="false" OnClick="imgUpdate_Click" />


Thanks.

Sanwar
Posted
Comments
Zoltán Zörgő 11-Oct-12 6:57am    
Have you checked the generated url in the html code?
sanwar_mal_jat 11-Oct-12 7:02am    
Thanks for reply.

Ya i am check my html code but my app key didn't render and not show the given app key url.
my html rendered code is
<input type="image" src="<%$%20AppSettings:PagePath%20%>_Images/btn-edit.jpg" id="MainContent_imgUpdate" name="ctl00$MainContent$imgUpdate">
Zoltán Zörgő 11-Oct-12 7:11am    
And what is your AppSettings section? Shouldn't that be appSettings instead (lower case "a")?
sanwar_mal_jat 11-Oct-12 7:13am    
In web config my app setting section is above mentioned

Zoltán Zörgő 11-Oct-12 7:17am    
I am not sure about the case sensivity here, but try: <%$appSettings:PagePath %>
But I don't know why you are using this, is the images folder on an other server instance? If not, simply use ImageUrl='/_Images/btn-edit.jpg'

1 solution

Use
ImageUrl='<%# ConfigurationManager.AppSettings["PagePath"] +"_Images/btn-edit.jpg" %>'


But now you need to call Page.DataBind in page load. If container of the control is another control other than Page then DataBind needs to be called for container control.

Thanks
Rohit
 
Share this answer
 
Comments
sanwar_mal_jat 12-Oct-12 7:37am    
Thanks Rohit ,
Me to 5.

This is very good solution , I am miss Page.DataBind(); method.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900