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

  • Home
  • SEARCH
  • 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 7510353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:12:26+00:00 2026-05-29T23:12:26+00:00

Within a web form I have the following jQuery setup to call a method

  • 0

Within a web form I have the following jQuery setup to call a method in my code behind file.

 <script src="js/jquery-1.7.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(function () {
            $("#newBtn").click(function () {
                $.ajax({
                    type: "POST",
                    url: "AJAXCaller.aspx/GetTimer",
                    data: "{}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    async: true,
                    cache: false

                });
                return false;
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <a href="#" class="link1" runat="server">Click here</a><br /><br />
    <asp:LinkButton ID="newBtn" runat="server" Text="ASP Link" />
    <asp:Label ID="time_lbl" runat="server" />
    </div>
    </form>
</body>

And within the code behind I have the following:

[WebMethod]
        public void GetTimer()
        {
            time_lbl.Text = DateTime.Now.ToString();
        }

I realize this currently does not work in the current syntax.

I’ve been able to access the method if I set it to static however I don’t want to just return a string or single value. I want to access a method that in turn access a web service to return a collection of data.

I would like to know if it is possible to perform something like this where I can call a method and have it update a field in the UI such as the above method where when called the server side script would to the ui a value for the date field?

Thanks in advance for any suggestions.

  • 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-29T23:12:29+00:00Added an answer on May 29, 2026 at 11:12 pm

    It is not at all possible because you cannot update any field on UI from server side.

    Instead of using WebMethod in aspx page use Asp.Net webservices instead to write web methods which can be called using ajax.

    ajax method has a success callback where you can grab the service response and then update the UI field by accessing it with appropriate selector.

    E.g

        $(function () {
            $("#newBtn").click(function () {
                $.ajax({
                    type: "POST",
                    url: "AJAXCaller.asmx/GetTimer",
                    data: "{}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    async: true,
                    cache: false,
                    success: function(data){
                         $("#ClientIdOftime_lbl").text(data);
                    }
    
                });
                return false;
            });
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a complex input form within a PHP based web application. To structure
Within an web form I have a some input fields <div id=search1> <div class=forminput>
I have a form called frmLogin. I have code within the Login_1Authenticate event handler
I have a .aspx web page, with a html form within it, this also
I have a web form sitting on an IIS instance on a server within
in web.xml i set my welcome file to a jsp within web.xml <welcome-file>WEB-INF/index.jsp</welcome-file> inside
I have worked within a web development company where we had our local machines,
I am using Tiles within my web-application. I have a standard-layout (standard.jsp) within the
Within a web project I am using jQuery and javascript to build a query
Within my web application I am using some custom validation for my form fields.

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.