title: Javascript onClick change border of image on ASP Page
body: <p>I have an ASP page that has 5 ASP ImageButtons. The images can be clicked and then a few things happen in the code behind. I also want the images to be outlined with a border when the user clicks it so they know that one has been selected. I am using javascript to accomplish the outline with a border. But my problem is that the border applies then the page refreshed and the border is gone. I know that the Imagebuttons are causing a post back, but how can I keep my ImageButtons outline after the postback?</p>
  
  <p>Javascript:</p>
  
  <pre><code>&lt;script language="JavaScript" type="text/javascript"&gt;
      function chnageborder(imageid) 
      {
          document.getElementById(imageid).style.border = "solid 2px #2F74D0";
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>ASP Imagebutton:</p>
  
  <pre><code>&lt;asp:ImageButton 
              ID="Image1" runat="server" 
              style="width: 48px; height: 48px; margin-right: 5px;" OnClick="Image1_Click" OnClientClick="javascript:chnageborder('Image1'); return true;"/&gt;
  </code></pre>