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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:00:44+00:00 2026-05-27T22:00:44+00:00

Having issues getting jQuery to work in this scenario: Visual Studio 2010 .Net 4.0

  • 0

Having issues getting jQuery to work in this scenario:
Visual Studio 2010
.Net 4.0 Framework
jQuery 1.7.1 (also tried 1.4.1)

I created a default ASP.Net Web Application in VS2010 allowing the tool to create a Master Page and the basic child pages (Defallt, About, etc). I then create a new page to test the jQuery – a child page using the default Master page. I put some div’s on the page and an HTML button and wired up the jQuery to change the background color of the div’s when the button is clicked. It does change the color for about 1/10th of a second but then changes right back. I tried a few different things like making the div’s disappear when the button is clicked – same result – disappears then comes right back. So I tried popping an alert (from jQuery code) when the button is clicked – this worked fine. It seems as though if I try to manipulate CSS there is an issue – otherwise things are fine. The page and site are extremely simple and basic. The HTML and script code for the page:

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="jQuery.aspx.vb" Inherits="TestWeb.jQuery" %>

<script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>

<script type="text/javascript">

    $(document).ready(function () {
        $("button").click(function () {
            $("p").css("background-color", "red"); 
        });
    });

</script>

<h2>
   jQuery Integration Testing
</h2>

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>

For some reason the content tags are not showing up when I past the code above so… The Script tags are contained within the <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> tag and the rest of the HTML is contained within the <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> tag

  • 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-27T22:00:45+00:00Added an answer on May 27, 2026 at 10:00 pm

    The button is submitting the page to the server, and so your background is changing then the page is getting refreshed back to the start. You need to add “return false” to the end of the click handler to cancel the navigation.

    <script type="text/javascript">
    
        $(document).ready(function () {
            $("button").click(function () {
                $("p").css("background-color", "red"); 
                return false;
            });
        });
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im having issues getting this to work, maybe its not even possible? I have
I'm having issues getting jQuery tooltips (using Tipsy) to work. The tooltips work fine
I am using this plugin: http://malsup.com/jquery/form/#getting-started I am having issues, getting it to submit
I'm having an issue getting this jQuery.ajax call to work. When the script executes
I'm having a few issues getting a simple JQuery function to work that fades
I'm having issues getting jQuery to work correctly while testing on Localhost. The function
I am having issues getting my JQuery Selector to access a particular HTML element.
I am having issues getting the -e and -d file test operators to work
I know it can be done but am having issues getting it to work.
We are having some issues getting SharePoint to work as we want it to.

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.