Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7797249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:37:29+00:00 2026-06-01T23:37:29+00:00

I’m trying to display the ImageUrl of an asp:ImageButton using AppSettings in my master

  • 0

I’m trying to display the ImageUrl of an asp:ImageButton using AppSettings in my master page like this:

 View.Master:
 ....
 <asp:ImageButton ID="aspShowHideButton" ImageUrl='<%# System.Configuration.ConfigurationManager.AppSettings("HomeDirectory").ToString()%>images/arrowUpButton.gif' runat="server" />

Unfortunately when I pull this up in the browser, this is the code that’s being rendered:

 <input type="image" name="ctl00$ctl00$aspContentMain$aspShowHideButton" id="aspContentMain_aspShowHideButton" onmouseover="ShowHideButtonMouseOver()" onmouseout="ShowHideButtonMouseOut()" src="../%3C%25#%20System.Configuration.ConfigurationManager.AppSettings(%22HomeDirectory%22).ToString()%25%3Eimages/arrowUpButton.gif" />

So it’s taking my ImageUrl literally, but I want it to take the value of the key, which is:

  ...
  <appSettings>
        ....
        <add key="HomeDirectory" value="/" />
        ....

I’ve tried, removing the “ToString()” function, I’ve tried “#” and “$” infront of the System.Configuration…. statement. I’ve also tinkered with trying to get this to work in the Page_Load function, using:

 Protected Sub Page_Load(....)
    If Not IsNothing(Master.FindControl("aspShowHideButton")) Then
       Dim ShowHideButton As ImageButton = Master.FindControl("aspShowHideButton")
       ShowHideButton.ImageUrl = System.Configuration.ConfigurationManager.AppSettings("HomeDirectory") + "images/arrowUpButton.gif"
    End If

But that didn’t seem to work either, I’m assuming because it could not find the control I was looking for (ie. aspShowHideButton).

Fundimentally, i want to have a key/value pair in my web.config file that allows me to change where my images are, and I want to be able to use this key/value pair in an ImageButton:ImageUrl on my master page, which seems like it must be a pretty popular thing to do. Any advise, direction, is appreciated!

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:37:30+00:00Added an answer on June 1, 2026 at 11:37 pm

    For using appsettings in a server tag, use this syntax:

    <%$ AppSettings:HomeDirectory %>
    

    But you won’t be able to concatenate the sufix of ImageUrl. Notice that if you want to refer home directory in an asp.net server control, ~ will do the trick.

     <asp:ImageButton ID="aspShowHideButton" ImageUrl="~/images/arrowUpButton.gif" runat="server"/>
    

    The easy solution

    Initialize the ImageUrl property on server side code, say for example the Page_Load event. There you will be able to use whatever server code you want.

    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
           this.aspShowHideButton.ImageUrl = System.Configuration.ConfigurationManager.AppSettings("HomeDirectory").ToString() + "images/arrowUpButton.gif";
        }
    }
    

    Now, if you really need to define that sort of concatenation in the ImageButton tag directly, you will need to use the Code Expression Builder. Read about that here.

    With Code Expression Builder, you will be able to use this kind of syntax in your ImageButton tag:

    ImageUrl="<%$ Code: System.Configuration.ConfigurationManager.AppSettings("HomeDirectory").ToString() + "images/arrowUpButton.gif" %>"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.