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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:53:43+00:00 2026-06-04T21:53:43+00:00

I am currently working on an ASP.NET MVC solution and have recently introduced both

  • 0

I am currently working on an ASP.NET MVC solution and have recently introduced both Knockout (an MVVM JS library) and Wijmo (a set of jQuery UI widgets).

With the introduction of Knockout I also need to have models on the client side, so for this purpose I am serializing the C# ViewModel and attaching it to the view using data-model="@Model.ToJson()". This allows me to retrieve the model from JS and apply some client-side love to everything.

However, knockout needs everything to be observables, so I need to declare a separate client-side ViewModel and map everything from the data-model object. This feels very much like duplicate effort and I’d like to avoid it somehow.

I’m hoping someone has a tool or technique to share that will allow me to render the knockout ViewModel directly from the server. Possible solution could include:

  • Custom JSON serialization to render the observable view model directly to the output in the data-model attribute.
  • Automatic client-side transformation (I’ve heard of ko-autobind, but am not sure if it would be a recommended path to take or how stable/complete it is)
  • Something I haven’t thought of

I’d like the solution to be generic and automatic, as my current approach of typing the observable client-side view models by hand is just too unproductive to be viable.

How are you solving this problem?

  • 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-04T21:53:45+00:00Added an answer on June 4, 2026 at 9:53 pm

    According to their tutorials it’s just a simple .map function

    If this is the ViewModel

    function Task(data) {
        this.title = ko.observable(data.title);
        this.isDone = ko.observable(data.isDone);
    }
    

    And this function get’s the data from the server, it uses the .map function to inject the server data right into the VM

    // Data
    var self = this;
    self.tasks = ko.observableArray([]);
    
    // Load initial state from server, convert it to Task instances, then populate self.tasks
    $.getJSON("/tasks", function(allData) {
        var mappedTasks = $.map(allData, function(item) {
            return new Task(item)
        });
        self.tasks(mappedTasks);
    });
    

    For ko mapping
    http://knockoutjs.com/documentation/plugins-mapping.html

    For auto-bind here’s an example

    https://groups.google.com/forum/#!msg/knockoutjs/IJTx37UXQVw/UTrWdEK1C-oJ

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

Sidebar

Related Questions

I'm currently working on an Asp.net MVC Web application. In my solution, there're two
I'm currently working in ASP.NET MVC 4 with EF 4.0. I have an unordered
I am currently working on an ASP.NET MVC 3 app where I have a
I am currently working on a prototype ASP.NET MVC 3 solution that will be
I am currently working on a ASP .Net MVC 3 application to do some
I'm working on an ASP.NET MVC solution that has a number of different menus.
I have been working with ASP.NET MVC for a couple of months now and
Currently I am working on small application in asp.net mvc. It is a some
I am currently working on my first asp.net mvc application. I am trying to
I'm working on a small library for for ASP.NET MVC 3 that should offer

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.