title: Span click alert using javascript with Asp.Net
body: <p>I have an Asp.Net button and a span tag which I have image for that.
  Now when I click the span element(i.e. the image) I should be able to click my button automatically and get an alert.</p>
  
  <p>I Can do it with a function as shown below on button click event but I'm not aware how to do when I click  element.</p>
  
  <p>CSS:</p>
  
  <pre><code>#container a span 
  {
  display:none; 
  background-image:url(images/alert.png); 
  background-repeat:no-repeat; 
  width:16px; 
  height:16px; 
  position:absolute;
  right:0px; 
  top:0px;
  } 
  
  #container a:hover span 
  {
  display:block;
  }
  </code></pre>
  
  <p>This is my span within <code>&lt;a&gt;</code>:</p>
  
  <pre><code>    &lt;div class='container a'&gt;&lt;a href='#'&gt;
      &lt;img src='uploads/" + document.getElementById("currentDirectory").value + "/" 
      + file.name + "' width='64' height='64'/&gt;
      &lt;span onclick='document.getElementById('&lt;%=btnAlert.ClientID%&gt;').click();'&gt;
      &lt;/span&gt;
      &lt;/a&gt;
      &lt;/div&gt;";
  </code></pre>
  
  <p>This is my simple Asp.Net Button:</p>
  
  <pre><code>&lt;asp:Button ID="btnAlert" runat="server" Text="Button" /&gt;
  </code></pre>
  
  <p>This is the code if I use a Javascript function:</p>
  
  <pre><code>  Protected Sub btnAlert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAlert.Click
       System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), "Script", "Somefunction();", True)
  End Sub
  </code></pre>