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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:37:34+00:00 2026-05-27T00:37:34+00:00

I know how to write a web-service but until now I used them with

  • 0

I know how to write a web-service but until now I used them with always ready scripts. What I want to do this time is, have a web-service will return a string and I want to display this string in a part of webpage. That part may be inside an update panel or not. I know how to use jquery. So my question is how do I call a web-service every 5 seconds and update a part of webpage with the result of web-service. This update should not interrupt any part of the page and never cause post-back.

How can I do that?

asp.net 4.0 , c# 4.0

  • 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-27T00:37:35+00:00Added an answer on May 27, 2026 at 12:37 am

    If your page is already using updatepanels then you could reuse the ms ajax libraries with no need for the jquery library at all.

    javascript:

      function GetMyString() {
       // Call a static page method to get your string
       PageMethods.GetMyStringWebMethod(OnSucceeded, OnFailed);
    

    }

     function OnSucceeded(result, userContext, methodName) {
        $get('yourDivContainer').innerHTML = '<b>' + result + '</b>';
       setTimeout("GetMyString()", 5000); 
        }
    
    
    function OnFailed(error, userContext, methodName) { }
    
    function pageLoad() {
          // On initial load and partial postbacks, 
       GetMyString();
    

    }

    Page Method in your code behind:

        [WebMethod]
        public static string GetMyStringWebMethod()
        {
    
            return "the string";
        }
    

    aspx:

    change asp:ScriptManager to have EnablePageMethods=”true”

    If you’re happy using jquery then just replace the Pagemethods call with an jquery.Ajax call passing in the GetMyStringWebMethod.aspx as the url and handle the string inset in the ajax success event.

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

Sidebar

Related Questions

I know I could write scripts and create jobs to run them, but at
I want to write a web service using Visual Studio. The service needs to
Does anybody know a good web service, where I can write and modify user
I know how to write the basic c# code to send emails, but I'm
So I know I can write my own HTML-encoding function like this: function getHTMLEncode(t)
Does anyone know how to write this var q = from c in customers
I need to write a .NET web service which will be consumed exclusively by
All, I'm attempting to write a Junit test that calls a Web Service client
I'm writing a REST web service on twisted and I want to use OAuth
I am constantly finding a good guide about how to write a web service

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.