In my previous article about Knockout.js, I explained Computed Observables in Knockout.js.
This article explains how to convert words into lowercase on the click of a button.
Step 1
Start Visual Studio.
Step 2
For executing application in knockout.js we need to add the knockout.js library to our website. To do that we will manage the NuGet Package. For this, right-click on the website and click on the NuGet Packages.
Step 3
In the NuGet packages we will search for Knockout.js and install Knockout.js library.

Step 4
After adding the library, now we will design the web form like the following:

Step 5
Now we need to add the knockout.js file to our application.
- <head runat="server">
- <title></title>
- <script src="Scripts/knockout-3.3.0.js"></script>
- </head>
I have added the knockout-3.3.0.js file because without this we can't do the knockout.js operation.
We write the following code for designing the form:
- <div>
- <p>First Name<strong data-bind="text: StartName"></strong></p>
- <p>Middle Name<strong data-bind="text: middlename"></strong></p>
- <p>LastName<strong data-bind="text: EndName"></strong></p>
- <input data-bind="value: StartName" />
- <input data-bind="value: middlename"? />
- <input data-bind="value: EndName" />
- <p>Hiiii!<strong data-bind="text: completeName"></strong></p>
- <button data-bind="click: capsName">Submit</button>
- </div>
In this I have taken three labels that indicate the first name, middle name, last name and I have also taken three textboxes for input from the user. Also, I will add a button for performing the operations.
Step 6
Now we will write the complete code for Knockout.js. By default I have taken the value Rahul kumar Sharma.
Complete Code
- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication4.WebForm1" %>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title></title>
- <script src="Scripts/knockout-3.3.0.js"></script>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <p>First Name<strong data-bind="text: StartName"></strong></p>
- <p>Middle Name<strong data-bind="text: middlename"></strong></p>
- <p>LastName<strong data-bind="text: EndName"></strong></p>
- <input data-bind="value: StartName" />
- <input data-bind="value: middlename"? />
- <input data-bind="value: EndName" />
- <p>Hiiii!<strong data-bind="text: completeName"></strong></p>
- <button data-bind="click: capsName">Submit</button>
- </div>
- </form>
- <script>
- function x()
- {
- this.StartName = ko.observable("Rahul");
- this.middlename = ko.observable("Kumar");
- this.EndName = ko.observable("Sharma");
- this.completeName = ko.computed(function ()
- {
- return this.StartName() + " " + this.middlename() + " " + this.EndName();
- }, this);
- this.capsName = function ()
- {
- var firstCaps = this.StartName();
- this.StartName(firstCaps.toLowerCase());
- var middleCaps = this.middlename();
- this.middlename(middleCaps.toLowerCase());
- var lastCaps = this.EndName();
- this.EndName(lastCaps.toLowerCase());
- }
- }
- ko.applyBindings(new x());
- </script>
- </body>
- </html>
Now we will execute that code using the F5 key. After execution the following window appears on the screen.

If we click on the submit button then all words are converted into lowercase.

Summary
In this article I explained how to convert words into lowercase on the click of a button.
I hope this article will be helpful for beginners if they want to start working on knockout.js in Visual Studio 2013.


Ravi KandelPosted Aug 13, 2016, 11:12 PM EDT
Nice
Bhuvanesh MohankumarPosted May 3, 2016, 8:40 AM EDT
Good one..
Santhakumar MunuswamyPosted Jul 30, 2015, 2:22 AM EDT
Thanks for nice article
Yatendra SharmaPosted Jul 29, 2015, 8:40 PM EDT
Rakesh Chavda thanx
Yatendra SharmaPosted Jul 29, 2015, 8:39 PM EDT
Gopi Chand thanx
Yatendra SharmaPosted Jul 29, 2015, 8:39 PM EDT
Nilesh Jadav thanx sir
Yatendra SharmaPosted Jul 29, 2015, 8:39 PM EDT
Sibeesh Venu thanx
Yatendra SharmaPosted Jul 29, 2015, 8:38 PM EDT
Rajeesh Menoth thanx
Yatendra SharmaPosted Jul 29, 2015, 8:37 PM EDT
Neeraj Kumar thanx
Shridhar SharmaPosted Jul 29, 2015, 2:11 PM EDT
nice one keep it up.
sreenivasa kPosted Jul 29, 2015, 10:53 AM EDT
good one
sreenivasa kPosted Jul 29, 2015, 10:53 AM EDT
good
RakeshPosted Jul 29, 2015, 5:54 AM EDT
Good one
Gopi ChandPosted Jul 29, 2015, 4:59 AM EDT
Its good one
Nilesh JadavPosted Jul 29, 2015, 2:47 AM EDT
Nice article sir
Sibeesh VenuTOP 100Posted Jul 29, 2015, 2:08 AM EDT
Nice Share.
Rajeesh MenothPosted Jul 29, 2015, 2:02 AM EDT
Good One
Neeraj KumarPosted Jul 29, 2015, 1:58 AM EDT
Good Work
Yatendra SharmaPosted Jul 29, 2015, 1:41 AM EDT
Debasis Saha thanx
Yatendra SharmaPosted Jul 29, 2015, 1:40 AM EDT
Atul Rawat thanx bro
Debasis SahaTOP 100Posted Jul 29, 2015, 1:29 AM EDT
Nice one..
Atul RawatPosted Jul 29, 2015, 1:23 AM EDT
nice article