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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:41:13+00:00 2026-05-20T17:41:13+00:00

I use asp.net and web forms. In my project I have asmx web service

  • 0

I use asp.net and web forms.
In my project I have asmx web service

[WebMethod]
    public string GetSomething()
    {
      // avoid circual reference(parent child)
      List<RetUsers> res = repo.GetAllUser().Select(c => new RetUsers {User_ID = c.User_ID,User_Name = c.User_Name,Date_Expire = c.Date_Expire }).ToList();
      string res1 = res.ToJson();
      // extension methods
      return res.ToJson();
    }

And result is in this format.

[
    {"User_ID":1,"User_Name":"Test 1","Date_Expire":null},
    {"User_ID":2,"User_Name":"Test 2","Date_Expire":null}
]

How can I append to label this result in $.ajax sucess to get this output:

1 – Test 1, 2 – Test 2.

  • 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-20T17:41:13+00:00Added an answer on May 20, 2026 at 5:41 pm

    Return the list instead, and use [ScriptMethod(ResponseFormat = ResponseFormat.Json)] attribute – it will create JSON object as return automatically:

    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)] 
    public List<RetUsers> GetSomething()
    {
      // avoid circual reference(parent child)
      List<RetUsers> res = repo.GetAllUser().Select(c => new RetUsers {User_ID = c.User_ID,User_Name = c.User_Name,Date_Expire = c.Date_Expire }).ToList();
    
      return res;
    }
    

    And on JS side:

    $.ajax(
    {
        type: "POST",
    async: true,
    url: YourMethodUrl,
    data: {some data},
    contentType: "application/json; charset=utf-8",
    dataType: "json",
        success: function(msg)
        {
            var resultAsJson = msg.d // your return result is JS array
            // Now you can loop over the array to get each object
            for(var i in resultAsJson)
            {
                var user = resultAsJson[i]
                var user_name = user.User_Name
                // Here you append that value to your label
            }
        }
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use SWFUpload with an ASP.NET Web Forms project. I need to
I have a Asp.net web site built on C# with Forms Authentication. We use
When building a multi-lingual website (with ASP.NET web forms), I'll use an HTTP module
Suppose you have two seperate ASP.NET Web Application projects that both need to use
I'm working on an asp.net web site. We have to use com interop to
I'm trying to use jQuery to get data from an ASP.NET web service (SharePoint
I work on a web game , I use asp.net mvc, linqtosql. I have
I have an ASP.NET web application with a web forms projects with dependencies on
I use the ASP.NET Development Web server (also known as the Visual Studio Development
I use ASP.NET and WCF services in a load balanced web server environment, using

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.