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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:30:34+00:00 2026-06-08T23:30:34+00:00

1.i have 2 question about knockout on asp.net. server side method: <WebMethod> Public Shared

  • 0

1.i have 2 question about knockout on asp.net.
server side method:

<WebMethod>
Public Shared Function foo() As List(Of person)
    Return New List(Of person)() From {New person With {.id = 1, .fname = "meysam"},
                                         New person With {.id = 2, .fname = "yasaman"}}.ToList
End Function

json and binding to knockout:

var VM = {};
$.getJSON("default.aspx/foo", function (data) {
    var tmp = JSON.stringify(data.d);
    VM.model =  
    ko.applyBindings(VM);
});

html:

<div data-bind="foreach: model">
<h3 data-bind="text: id">
</h3>
<p>
    Name: <span data-bind="text: fname"></span>
</p>

but when i run in browser.No nothing will happen.fname,id Will be displayed.

2.what The difference between $.getJSONand dataType:json?

 $.getJSON("default.aspx/foo", function (data) {
    var tmp = JSON.stringify(data.d);
});

and

$.ajax({
type:"post",
url:"default.aspx/foo",
contentType:"application/json;charset=utf-8",
dataType:"json",
success:function(data){}
})
  • 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-06-08T23:30:35+00:00Added an answer on June 8, 2026 at 11:30 pm

    About your knockout question:

    Here’s code to solve your issue:

    Output

    enter image description here

    ASPX code behind

        [WebMethod]
        public static IEnumerable<KnoPerson> GetPeople()
        {
            return Builder<KnoPerson>.CreateListOfSize(10).Build();
        }
    
    public class KnoPerson
    {
        public int ID { get; set; }
        public int FirstName { get; set; }
    }
    

    ASPX

    <script type="text/javascript" src="Scripts/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="Scripts/knockout-2.1.0.js"></script>
    <script type="text/javascript" src="Scripts/knockout.mapping-latest.js"></script>
    <script type="text/javascript">
        $(function () {
            var model = {};
            $.ajax({
                url: "KnockoutBindingFromPageMethod.aspx/GetPeople",
                data: null,
                type: "POST",
                dataType: "json",
                contentType: "application/json",
                cache: false,
                async: false,
                success: function (myData) {
                    model.people = ko.mapping.fromJS(myData.d);
                    model.yo = ko.observable("plop");
                    ko.applyBindings(model);
                },
                error: function (xhr) {
                    alert(xhr.responseText);
                }
            });
        });
    </script>
    
        <div data-bind="text: yo"></div>
        <div data-bind="foreach: people">
            <h3 data-bind="text: ID"></h3>
            <p>
                Name: <span data-bind="text: FirstName"></span>
            </p>
        </div>
    

    2.what The difference between $.getJSONand dataType:json?

    .getJSON is a shortcut, and it internally uses .ajax

    The .getJSON function sets the following properties:

    • dataType: “json”

    • type: "GET"

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

Sidebar

Related Questions

Have a question about the design/usage of asp.net mvc here. In the html helper
I'm learning asp.net. I have question about example buttons I can use two types
I have question about managing transaction in asp.net application. For example i have application
I have question about this plugin system: .NET 4.0 ASP.NET MVC 3 plug-in architecture
I have question about my code which does the Hoare Partition Method. Here is
every night i have a trigger that executes asp.net page with method that first
I have question about how I can save the result of function I have
I have question about removing element from QList. myclass.h: class node2D : public QObject
Question about JS Knockout library - I have three inputs, all data-Bind-ed to the
Have a question about calling one prototype function in another prototype function. for instance

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.