title: Settings the ImageUrl in an ImageButton on a master page with an AppSettings key
body: <p>I'm trying to display the ImageUrl of an asp:ImageButton using AppSettings in my master page like this:</p>
  
  <pre><code> View.Master:
   ....
   &lt;asp:ImageButton ID="aspShowHideButton" ImageUrl='&lt;%# System.Configuration.ConfigurationManager.AppSettings("HomeDirectory").ToString()%&gt;images/arrowUpButton.gif' runat="server" /&gt;
  </code></pre>
  
  <p>Unfortunately when I pull this up in the browser, this is the code that's being rendered:</p>
  
  <pre><code> &lt;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" /&gt;
  </code></pre>
  
  <p>So it's taking my ImageUrl literally, but I want it to take the value of the key, which is:   </p>
  
  <pre><code>  ...
    &lt;appSettings&gt;
          ....
          &lt;add key="HomeDirectory" value="/" /&gt;
          ....
  </code></pre>
  
  <p>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:</p>
  
  <pre><code> 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
  </code></pre>
  
  <p>But that didn't seem to work either, I'm assuming because it could not find the control I was looking for (ie. aspShowHideButton).</p>
  
  <p>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!</p>
  
  <p>Thanks!</p>