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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:54:55+00:00 2026-06-10T22:54:55+00:00

I have been trying to call JQuery code from Button1 but whenever I click

  • 0

I have been trying to call JQuery code from Button1 but whenever I click the button nothing happens. I suspect there is something is missing here.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="Scripts/jquery-1.4.1.js"/>
    <script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"/>
    <script type="text/javascript">
    $(document).ready(function(){
        $("#Button1").click(function () {
            alert("Hello");
         });
    });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" />    
    </div>
    </form>
</body>
</html>

Please Help me as I am new to Jquery with ASP

Update!
Rendered HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title>
    <script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"/>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#B1").click(function () {
                alert("Hello");
            });
        });
    </script>
</head>
<body>

    <form name="form1" method="post" action="Default.aspx" id="form1" enctype="multipart/form-data">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTExNzQxODc4NzgPZBYCAgMPFgIeB2VuY3R5cGUFE211bHRpcGFydC9mb3JtLWRhdGEWAgITDzwrAA0AZBgBBQlHcmlkVmlldzEPZ2S859s2HXOd3dMN1a3AFBBA24YTWA==" />
</div>

<div>

    <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBwLCh8GMCAKl1bK4CQK1qbSRCwKM54rGBgK7q7GGCALWlM+bAgLe7+btDB1tn9tYIpN00SJIvx3i3VxCTOP7" />
</div>


    <input type="submit" name="B1" value="Button" id="B1" />

    </form>

</body>
</html>
  • 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-10T22:54:57+00:00Added an answer on June 10, 2026 at 10:54 pm

    you can try add class to button element, and find this in div context:

    Javascript:

    $(document).ready(function(){
    
       var $context = $('#containerForm').find('form'); 
       $context.find('.mybutton').bind('click', function (event) {
          alert("Hello");
       });
    });
    

    Html:

    <body>
        <div id="containerForm">
           <form id="form1" runat="server">
           <div runat="server">
               <asp:Button ID="Button1" runat="server" Text="Button" class="mybutton" />    
           </div>
           </form>
        </div>
    </body>
    

    Edit:

    or, find button element with this selector $context.find('input[name*="Button1"]'), using contexts is to have better performance.

    Edit II:

    Your code work well (see this). You should verify if the file “Scripts/jquery-1.4.1.min.js” is loading fine, you might be positioned in a path that is not on the same level of folder “Scripts“, depending on the level or as this set up the project, could you put “Scripts/jquery-1.4.1.min.js“, but you have to be careful if you have “/MyProyect/Scripts/jquery-1.4.1.min.js“.

    To verify this, you can use the “fiddler“, and find http status code 400.

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

Sidebar

Related Questions

I have been trying to call a mapreduce job from a simple java program
I have been trying to call the NewPixelRegionIterator function in ImageMagick's library from C#
I have been trying to get a jquery ajax function to return data from
Hi I have been trying to make a ajax call to a JSP page.
I am trying to use Qunit to test some code, but I have some
I have been experimenting and trying to learn JQuery, using AJAX to consume a
Have been trying to encrypt an xml file to a string so that I
Have have been trying to make a validator for my xml files. I have
I have been trying to setup git for our web development team unsuccessfully. Some
I have been trying for almost a week now to create an SQLite database

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.