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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:57:42+00:00 2026-06-17T12:57:42+00:00

Hi; i try to learn knockout.js using asp.net mvc razor. i have been written

  • 0

Hi; i try to learn knockout.js using asp.net mvc razor. i have been written some codes below but http://localhost:56238/Contact/SendMessage is empty. i see only html control. How to bind ViewModel to UI by using knockout.js


@{
    ViewBag.Title = "SendMessage";
}

<h2>SendMessage</h2>

<script src="/Scripts/knockout-2.1.0.js" type="text/javascript"></script>
<script type="text/javascript">


    $(document).ready(function () {


        function AppViewModel() {
            this.firstName = ko.observable("Bert");
            this.lastName = ko.observable("Bertington");

            this.fullName = ko.computed(function () {
                return this.firstName() + " " + this.lastName();
            }, this);

            this.capitalizeLastName = function () {
                var currentVal = this.lastName();        // Read the current value
                this.lastName(currentVal.toUpperCase()); // Write back a modified value
            };


            $(document).ready(function () { ko.applyBindings(new AppViewModel()); })
        }



    });
</script>

<p>First name: <strong data-bind="text: firstName"></strong></p>
<p>Last name: <strong data-bind="text: lastName"></strong></p>

<p>First name: <input data-bind="value: firstName" /></p>
<p>Last name: <input data-bind="value: lastName" /></p>

<p>Full name: <strong data-bind="text: fullName"></strong></p>

<button data-bind="click: capitalizeLastName">Go caps</button>
  • 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-17T12:57:43+00:00Added an answer on June 17, 2026 at 12:57 pm

    ko.applyBindings never executed in your code, you must put it somewhere outside the ViewModel. “this” in computed not gonna work because it does not point to the view model.

    It should be something like this:

    <script type="text/javascript">
        function AppViewModel() {
                var self = this;
    
                this.firstName = ko.observable("Bert");
                this.lastName = ko.observable("Bertington");
    
                this.fullName = ko.computed(function () {
                    return self.firstName() + " " + self.lastName();
                }, this);
    
                this.capitalizeLastName = function () {
                    var currentVal = this.lastName();        // Read the current value
                    this.lastName(currentVal.toUpperCase()); // Write back a modified value
                };
            }
    
        $(document).ready(function () {
            ko.applyBindings(new AppViewModel()); 
        });
    </script>
    

    One more thing, I see you’re using jquery without including jquery lib.

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

Sidebar

Related Questions

i try to learn asp.net Profile management. But i added below xml firstName,LastName and
I am following along with the music store example to try learn ASP.NET MVC.
Hi! i try to learn Asp.net MVC.i created a sample application to learn it.
In my bid to try and learn some more about WPF I've been looking
I'm using macincloud service to try/play/learn about building iPhone apps. I have a dummy
I am using org.aspectj.lang.annotation.Pointcut . I have an interface com.home.learn.Try. I want a pointcut
I try to learn OpenGL by creating some sort of 3D Modeler application using
I try to learn Maya (3d Software) API with Python, but I encounter some
Some projects that I try and learn from don't have a schema.rb file, why
I'm new to the programming world and have been experimenting to try and learn

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.