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 6787145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:19:50+00:00 2026-05-26T17:19:50+00:00

I have an Asp.Net button and a span tag which I have image for

  • 0

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.

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.

CSS:

#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;
}

This is my span within <a>:

    <div class='container a'><a href='#'>
    <img src='uploads/" + document.getElementById("currentDirectory").value + "/" 
    + file.name + "' width='64' height='64'/>
    <span onclick='document.getElementById('<%=btnAlert.ClientID%>').click();'>
    </span>
    </a>
    </div>";

This is my simple Asp.Net Button:

<asp:Button ID="btnAlert" runat="server" Text="Button" />

This is the code if I use a Javascript function:

  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
  • 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-05-26T17:19:51+00:00Added an answer on May 26, 2026 at 5:19 pm

    Works fine for me.
    You have no inner content in your span so maybe that’s why it’s not able to trigger the onclick because it’s not taking up any space in your dom. So when you think you’re clicking on it you’re actually not hitting it since it’s not taking up any space.

    Try adding some content in the span like my example.
    If that isn’t working double check to make sure your id is correct for the button.

    <input type="button" id="mybutton" onclick="alert('hello')">
    <span onclick="document.getElementById('mybutton').click()">My Span</span>
    

    jsFiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET page which has a button it it. The button click
I noticed that in chrome if you have an asp.net image button and do
I have a custom ASP.NET button with an image element inside it (and an
I have a ASP.NET page with an asp:button that is not visible. I can't
I have an asp.net button, that when clicked calls a code behind function. The
I have an ASP.NET page which has an asp.net button control in it. When
I have an ASP.Net-Button which, when clicked, executes client side and server side code.
I know that ASP.NET controls such as the button have the postback event model.
I have a ASP.Net button control in my page: I have JQuery click event
I have the javascript code below which disables an asp.net button during page postback.

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.