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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:49:36+00:00 2026-05-20T07:49:36+00:00

I am learning jQuery and as part of that i tried following code.. It

  • 0

I am learning jQuery and as part of that i tried following code.. It was simple exercise to see if i can manipulate server controls using Jquery.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestForm.aspx.cs"     Inherits="TestForm" %>
<!DOCTYPE html>
<html>
<head>
<title></title>
  <script src="http://code.jquery.com/jquery-1.5.js" type="text/jscript"></script>
</head>
<body>

  <p>Hello</p>
  <a href="#">Click to hide me too</a>
  <p>Here is another paragraph</p>
  <input id="HTMLButton" type="button" value="HTML Button"  />

<script type="text/jscript" >
  //Desired Behavior. The Command button outside Form Attribute works are desired. 
  $("input").click(function () {
    $("#NameText").toggle()
  });

  $("#<%=WebCtrlJScript.ClientID%>").click(function () {
    alert("Button btnToggleDiv from Name Clicked");
    $("#NameText").toggle();
  });

  //This is simple HTML button inside Form Element.
  $("#HTMLInsideForm").click(function () {
    alert("Button HTMLInsideForm Clicked");
      $("#NameText").toggle()
  });


</script>

<script type="text/javascript">
  function NameText() {
    alert("WebCtrlOnClientClick Clicked");
    $("#NameText").hide();
    this.blur();
  }

</script>
<form id="Form1" runat="server">
<div id="NameText">
  <table>
    <tr>
      <td>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
      </td>
      <td>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
      </td>
    </tr>
  </table>
</div>
<div>
  <asp:Button ID="WebCtrlOnClientClick" runat="server" Text=".Net Button" OnClientClick="NameText()"/>
  <asp:Button ID="WebCtrlJScript" runat="server" Text="JScript Button"/>
  <input id="HTMLInsideForm" type="button" value="HTML Button(Inside Div)" />
</div>
</form>
</body>
</html>       

It seems like anything i had inside form tags is not working.. for example first button with value=”HTML Button” can toggle div element with ID =”NameText” where as other buttons irrespective of whether they are HTML or server controls cannot hide the div. I am not sure what i am missing.

Thanks
CSC

  • 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-20T07:49:37+00:00Added an answer on May 20, 2026 at 7:49 am

    You need to use

    $('#<%= Button1.ClientID %>')...

    Unless you’re using .Net 4.0. In which case you can use the solution presented here: http://weblogs.asp.net/asptest/archive/2009/01/06/asp-net-4-0-clientid-overview.aspx

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

Sidebar

Related Questions

I am learning jQuery from book Learning jQuery, and found part of code that
I'm learning jQuery and am about to write some pages using intensively that library.
Still learning jquery here and I've tried to setup a set of divs that
So I'm learning jQuery Mobile and I'm trying to run the following code below
As part of learning jQuery, I decided to do a simple tic-tac-toe game in
I am learning jQuery UI. I downloaded a code in which the author made
i have some knowledge of css,jQuery,Grails,django,servlets and jsp still i can't see me designing
Learning jquery, so please be kind :) Using PHP, I have a table with
I'm new to jquery and has some problems with the following code, the code
For learning jQuery UI dialog, I have the code defined below. I need 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.