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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:46:47+00:00 2026-05-27T10:46:47+00:00

i am using < div onclick=> to call the server side .How can i

  • 0

i am using < div onclick=”””> to call the server side .How can i avoid full page refresh when user click the < div>?

Here is my coding.

HTML

 <asp:UpdatePanel ID="updatePanel1" runat="server">  <ContentTemplate>
 <div id ="cde" runat="server" style="background-color: #00FFFF" > </div>
  <asp:Label ID="Label1" runat="server" Text="Label"> </asp:Label>
 </ContentTemplate> </asp:UpdatePanel>

Server side

 protected void Page_Load(object sender, EventArgs e)
    {
        //--Register for div onclick function --
        cde.Attributes["onclick"] = ClientScript.GetPostBackEventReference(this, "divMember_Click");
        //**Register for div onclick function**
    }
protected void divMember_Click()
    {

        this.Label1.Text = System.DateTime.Now.ToString();

    }
    public void RaisePostBackEvent(string eventArgument)
    {
        if (!string.IsNullOrEmpty(eventArgument))
        {

            if (eventArgument == "divMember_Click")
            {

                divMember_Click();

            }

        }
    }

I try putting the label within the update panel . But postback will still occur. How can i refresh the label without full page reload?

  • 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-27T10:46:48+00:00Added an answer on May 27, 2026 at 10:46 am

    you can use Jquery .ajax function or pagemethod.YourWebMethod.

    Create Web Method in your C# Code and call it using these two functions.

    You can do Page Method by EnabledPageMethod=”true” in script Manager and use Jquery .ajax function put jquery java script.

    This will be on page behind code (create Web Method):

    public partial class _Default : Page 
    {
    
      [WebMethod]
    
      public static string GetDate()
    
    
    
    {
    

    return DateTime.Now.ToString();

    }
    
    }
    

    As referenced in Default.aspx, this is java script:

    $(document).ready(function() {
      // Add the page method call as an onclick handler for the div.
      $("#Result").click(function() {
        $.ajax({
          type: "POST",
          url: "Default.aspx/GetDate",
          data: "{}",
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function(msg) {
            // Replace the div's content with the page method's return.
            $("#Result").text(msg.d);
          }
        });
      });
    });
    
        <head>
      <title>Calling a page method with jQuery</title>
      <script type="text/javascript" src="jquery-1.2.6.min.js"></script>
      <script type="text/javascript" src="Default.js"></script>
    </head>
    <body>
      <div id="Result">Click here for the time.</div>
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page ItemList that shows a list of items using div's. After
How can i fadeOut a div using jquery
How can I get content of a DIV using regular expression. What I need
I can select the first item in the div using $('.class:first') Now since I
Here is what I'm trying to do: Click a button on my page, which
I have click-able images in my html page that call a javascript function... however
I'm using Div's, now I have to handle 2 Events with one Div-Click.. On
With buttons, I can call the click() method on them to have a click
HTML: <table border=1px> <tr> <td colspan=2> <div class=commentLink> <a onclick=ShowBox.call(this); return false; href=#>Comment</a> </div>
When I click on the following div: <div id=Result>Click here for the time.</div> I

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.