SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
Nguyễn Ngọc Dũng
P a g e 1 | 28
https://nndung179.wordpress.com/
Contents
O/ Things I do in this tutorial........................................................................................................................2
I/ Database ....................................................................................................................................................2
II/ Create New Project ..................................................................................................................................3
2.1/ Create New Project MVC4................................................................................................................3
2.2/ Add Controller + Add View ..............................................................................................................4
2.3/ Add Folder DTO + DAO...................................................................................................................6
2.3.1/ Add Database via LINQ TO SQL...............................................................................................6
2.3.2/ Add class handle data to DAO folder .......................................................................................10
2.3.3/ Create Stored Procedure for SELECT DATA ..........................................................................11
2.3.4/ Add Stored Procedure to StudentDB.dbml...............................................................................11
2.3.5/ Code handle Get List Student of DAO class.............................................................................12
2.3.6/ Add handle function to Controller ............................................................................................13
III/ Ajax + Knockout.js + Jquery ................................................................................................................13
3.1/ Change something in your layout ....................................................................................................14
3.2/ Create Folder contain Javascript file................................................................................................14
3.3/ Go to view Index + doing something...............................................................................................16
3.4/ Put some code to StudentJS.js .........................................................................................................17
3.4.1/ Create Object with Contructor..................................................................................................17
3.4.2/ Function to Get data..................................................................................................................18
3.4.3/ Create View Model with Knockout.js ......................................................................................18
3.4.4/ Update your View Index...........................................................................................................19
3.4.5/ Run............................................................................................................................................20
IV/ Bootstrap...............................................................................................................................................20
4.1/ Download and Install.......................................................................................................................20
4.2/ How to use .......................................................................................................................................24
4.3/ Run and feel cool .............................................................................................................................26
V/ Source Code...........................................................................................................................................28
Nguyễn Ngọc Dũng
P a g e 2 | 28
https://nndung179.wordpress.com/
MVC4 – knockout.js – Bootstrap –
Step by Step – Part 1
Hello you guys.
In this article. I’m going to show you how to use MVC4 and Ajax
via KNOCKOUT.js. You guys just follow step by step of this article.
In the Part 1 => Just Interface and Select student
O/ Things I do in this tutorial
+ MVC 4 – Microsoft
+ knockout.js
+ Jquery
+ Bootstrap
+ Microsoft SQL
+ Stored Procedure
=> Enjoy your meal :)
I/ Database
Nguyễn Ngọc Dũng
P a g e 3 | 28
https://nndung179.wordpress.com/
II/ Create New Project
2.1/ Create New Project MVC4
click OK to create new Project
Nguyễn Ngọc Dũng
P a g e 4 | 28
https://nndung179.wordpress.com/
2.2/ Add Controller + Add View
I name this controller “Home”
And then I add view for this HomeController
Nguyễn Ngọc Dũng
P a g e 5 | 28
https://nndung179.wordpress.com/
I use the default layout of this template
Nguyễn Ngọc Dũng
P a g e 6 | 28
https://nndung179.wordpress.com/
2.3/ Add Folder DTO + DAO
DTO: Contain Database and object
DAO: Handle database (select, insert, update)
In folder Models => I create DTO and DAO folder
2.3.1/ Add Database via LINQ TO SQL
Right click on folder DTO => Add => New Item
Choose Data => LINQ to SQL Classes => Name it “StudentDB.dbml”
Nguyễn Ngọc Dũng
P a g e 7 | 28
https://nndung179.wordpress.com/
The result we get from image above is a blank screen. Next thing, we’re going to do
is:
+ add connection from Server Explorer to the database
+ Drag database from Server Explorer to StudentDB.dbml
Nguyễn Ngọc Dũng
P a g e 8 | 28
https://nndung179.wordpress.com/
Nguyễn Ngọc Dũng
P a g e 9 | 28
https://nndung179.wordpress.com/
Just Drag this table to left pane of StudenDB.dbml
Nguyễn Ngọc Dũng
P a g e 10 | 28
https://nndung179.wordpress.com/
2.3.2/ Add class handle data to DAO folder
Do following things like me
Nguyễn Ngọc Dũng
P a g e 11 | 28
https://nndung179.wordpress.com/
2.3.3/ Create Stored Procedure for SELECT DATA
2.3.4/ Add Stored Procedure to StudentDB.dbml
+ Go to Server explorer => Expand folder Stored Procedure Folder. You’ll see the
stored you’ve just created
Nguyễn Ngọc Dũng
P a g e 12 | 28
https://nndung179.wordpress.com/
+ Just Drag this stored to your Right Pane of StudentDB.dbml + Save it via (Ctrl +
S)
2.3.5/ Code handle Get List Student of DAO class
Go to StudentDAO.cs and take this code to select the list of student. Of course, you
can create your own function
Nguyễn Ngọc Dũng
P a g e 13 | 28
https://nndung179.wordpress.com/
2.3.6/ Add handle function to Controller
III/ Ajax + Knockout.js + Jquery
Nguyễn Ngọc Dũng
P a g e 14 | 28
https://nndung179.wordpress.com/
3.1/ Change something in your layout
Go to Shared => _Layout.cshtml => Change something as follow
I added 2 section to this layout.
+ David_Custom_CSS: to insert your custom link css
+ David_Custom_Scripts: to Insert your custom js link
3.2/ Create Folder contain Javascript file
+ Add folder and name it “My Script”
Nguyễn Ngọc Dũng
P a g e 15 | 28
https://nndung179.wordpress.com/
+ Add javascript file to Folder “My Script” and name this javascript file
“StudentJS.js“
Nguyễn Ngọc Dũng
P a g e 16 | 28
https://nndung179.wordpress.com/
3.3/ Go to view Index + doing something
In this section, you must add the link to reference to related .js file and .css file
Nguyễn Ngọc Dũng
P a g e 17 | 28
https://nndung179.wordpress.com/
3.4/ Put some code to StudentJS.js
3.4.1/ Create Object with Contructor
If you don’t understand this code. You just go to GOOGLE => Search “Object In
Javascript“. I’m not going to explain this to you. Because it’s out of this article.
Nguyễn Ngọc Dũng
P a g e 18 | 28
https://nndung179.wordpress.com/
3.4.2/ Function to Get data
I used ajax of Jquery to call the method in controller to recieve the data and store it in
array that I’m going to create in the model in next step.
3.4.3/ Create View Model with Knockout.js
You can figure how knockout.js work in this link: http://knockoutjs.com/
Nguyễn Ngọc Dũng
P a g e 19 | 28
https://nndung179.wordpress.com/
3.4.4/ Update your View Index
Nguyễn Ngọc Dũng
P a g e 20 | 28
https://nndung179.wordpress.com/
3.4.5/ Run
+ It worked, but it is so ugly.
IV/ Bootstrap
If you’re really want to get a good interface. I recommend bootstrap.
4.1/ Download and Install
+ First, You need to access the link: http://getbootstrap.com/
Nguyễn Ngọc Dũng
P a g e 21 | 28
https://nndung179.wordpress.com/
+ Download this. And you’ll get this
Nguyễn Ngọc Dũng
P a g e 22 | 28
https://nndung179.wordpress.com/
+ Extract it, and go to this folder, and copy all files
+ Create Folder of Project, and name it “Bootstrap“
Nguyễn Ngọc Dũng
P a g e 23 | 28
https://nndung179.wordpress.com/
+ Parse all file you’ve just copied from bootstrap folder
+ Expand all folder contain in “Bootstrap“. Place the link like below
Nguyễn Ngọc Dũng
P a g e 24 | 28
https://nndung179.wordpress.com/
4.2/ How to use
Access like image below:
+ Go to table
Nguyễn Ngọc Dũng
P a g e 25 | 28
https://nndung179.wordpress.com/
+ You now see much more example for using class of bootstrap. I’m going to choose
one
+ I choose “table table hover“. I must update my View Index like this.
Nguyễn Ngọc Dũng
P a g e 26 | 28
https://nndung179.wordpress.com/
4.3/ Run and feel cool
+ The problem is the button is so ugly. I want it to be nice and cool. Like prior index.
We choose button instead table
+ It’s going to show you like below
Nguyễn Ngọc Dũng
P a g e 27 | 28
https://nndung179.wordpress.com/
+ See examples and do like this
+ Ok let’s update the View Index again
Nguyễn Ngọc Dũng
P a g e 28 | 28
https://nndung179.wordpress.com/
+ Run again and enjoy the tutorial :)
V/ Source Code
http://www.mediafire.com/download/jbua22nv4ekljk6/Knockout_1.rar

Contenu connexe

En vedette

"What Is RUS?" - Requisite Unifying Structure (RUS) - Requisite Technology (2...
"What Is RUS?" - Requisite Unifying Structure (RUS) - Requisite Technology (2..."What Is RUS?" - Requisite Unifying Structure (RUS) - Requisite Technology (2...
"What Is RUS?" - Requisite Unifying Structure (RUS) - Requisite Technology (2...Lowell Fields Millburn
 
3 maharaj-aging-drc
3 maharaj-aging-drc3 maharaj-aging-drc
3 maharaj-aging-drcifa2012_2
 
RewardTivity instructions
RewardTivity instructionsRewardTivity instructions
RewardTivity instructionsRaceReach.com
 
2 carmel- assisted living - prague may 20 2012-final
2 carmel- assisted living - prague may 20 2012-final2 carmel- assisted living - prague may 20 2012-final
2 carmel- assisted living - prague may 20 2012-finalifa2012_2
 
3 stone-older people’s commissioner for wales ifa 2012
3 stone-older people’s commissioner for wales ifa 20123 stone-older people’s commissioner for wales ifa 2012
3 stone-older people’s commissioner for wales ifa 2012ifa2012_2
 
Pittsburgh talk on Emergence and in Gauge/Gravity Dualities
Pittsburgh talk on Emergence and in Gauge/Gravity DualitiesPittsburgh talk on Emergence and in Gauge/Gravity Dualities
Pittsburgh talk on Emergence and in Gauge/Gravity DualitiesSebastian De Haro
 
Meredith M, Powerpoints lesson 1
Meredith M, Powerpoints lesson 1Meredith M, Powerpoints lesson 1
Meredith M, Powerpoints lesson 1MeredithM17
 
Dualitiy in Contemporary Mathematics Wuppertal
Dualitiy in Contemporary Mathematics WuppertalDualitiy in Contemporary Mathematics Wuppertal
Dualitiy in Contemporary Mathematics WuppertalSebastian De Haro
 
Капитальный ремонт "Флейты"
Капитальный ремонт "Флейты"Капитальный ремонт "Флейты"
Капитальный ремонт "Флейты"Alexander Erlikh
 
Econ drought conflict presentation
Econ drought conflict presentationEcon drought conflict presentation
Econ drought conflict presentationTim_Maher
 
End of year 11 12 presentation
End of year 11 12 presentationEnd of year 11 12 presentation
End of year 11 12 presentationtaylormjty
 

En vedette (14)

"What Is RUS?" - Requisite Unifying Structure (RUS) - Requisite Technology (2...
"What Is RUS?" - Requisite Unifying Structure (RUS) - Requisite Technology (2..."What Is RUS?" - Requisite Unifying Structure (RUS) - Requisite Technology (2...
"What Is RUS?" - Requisite Unifying Structure (RUS) - Requisite Technology (2...
 
3 maharaj-aging-drc
3 maharaj-aging-drc3 maharaj-aging-drc
3 maharaj-aging-drc
 
RewardTivity instructions
RewardTivity instructionsRewardTivity instructions
RewardTivity instructions
 
Organo gold
Organo goldOrgano gold
Organo gold
 
2 carmel- assisted living - prague may 20 2012-final
2 carmel- assisted living - prague may 20 2012-final2 carmel- assisted living - prague may 20 2012-final
2 carmel- assisted living - prague may 20 2012-final
 
3 stone-older people’s commissioner for wales ifa 2012
3 stone-older people’s commissioner for wales ifa 20123 stone-older people’s commissioner for wales ifa 2012
3 stone-older people’s commissioner for wales ifa 2012
 
God knows
God knowsGod knows
God knows
 
Pittsburgh talk on Emergence and in Gauge/Gravity Dualities
Pittsburgh talk on Emergence and in Gauge/Gravity DualitiesPittsburgh talk on Emergence and in Gauge/Gravity Dualities
Pittsburgh talk on Emergence and in Gauge/Gravity Dualities
 
Meredith M, Powerpoints lesson 1
Meredith M, Powerpoints lesson 1Meredith M, Powerpoints lesson 1
Meredith M, Powerpoints lesson 1
 
Dualitiy in Contemporary Mathematics Wuppertal
Dualitiy in Contemporary Mathematics WuppertalDualitiy in Contemporary Mathematics Wuppertal
Dualitiy in Contemporary Mathematics Wuppertal
 
Капитальный ремонт "Флейты"
Капитальный ремонт "Флейты"Капитальный ремонт "Флейты"
Капитальный ремонт "Флейты"
 
Econ drought conflict presentation
Econ drought conflict presentationEcon drought conflict presentation
Econ drought conflict presentation
 
Studiemarathon
StudiemarathonStudiemarathon
Studiemarathon
 
End of year 11 12 presentation
End of year 11 12 presentationEnd of year 11 12 presentation
End of year 11 12 presentation
 

Similaire à MVC4 – knockout.js – bootstrap – step by step – part 1

Javascript native OOP - 3 layers
Javascript native OOP - 3 layers Javascript native OOP - 3 layers
Javascript native OOP - 3 layers David Nguyen
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!David Gibbons
 
How to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScriptHow to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScriptKaty Slemon
 
Virtual Environment and Web development using Django
Virtual Environment and Web development using DjangoVirtual Environment and Web development using Django
Virtual Environment and Web development using DjangoSunil kumar Mohanty
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...Horacio Gonzalez
 
Django tutorial
Django tutorialDjango tutorial
Django tutorialKsd Che
 
Mvc4 crud operations.-kemuning senja
Mvc4 crud operations.-kemuning senjaMvc4 crud operations.-kemuning senja
Mvc4 crud operations.-kemuning senjaalifha12
 
Collective.amberjack ploneconf2010
Collective.amberjack ploneconf2010Collective.amberjack ploneconf2010
Collective.amberjack ploneconf2010Massimo Azzolini
 
Cis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry universityCis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry universitylhkslkdh89009
 
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
Decoupling Drupal mit dem Lupus Nuxt.js Drupal StackDecoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stacknuppla
 
BreizhBeans - Web components
BreizhBeans - Web componentsBreizhBeans - Web components
BreizhBeans - Web componentsHoracio Gonzalez
 
Download disabled slideshare ppts, Download from slideshare without login
Download disabled  slideshare ppts, Download from slideshare without loginDownload disabled  slideshare ppts, Download from slideshare without login
Download disabled slideshare ppts, Download from slideshare without loginPE Mahmoud Jad
 
Dolibarr - information for developers and partners - devcamp lyon 2019
Dolibarr - information for developers and partners - devcamp lyon 2019Dolibarr - information for developers and partners - devcamp lyon 2019
Dolibarr - information for developers and partners - devcamp lyon 2019Laurent Destailleur
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoJames Casey
 

Similaire à MVC4 – knockout.js – bootstrap – step by step – part 1 (20)

Javascript native OOP - 3 layers
Javascript native OOP - 3 layers Javascript native OOP - 3 layers
Javascript native OOP - 3 layers
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
 
DotNetNuke
DotNetNukeDotNetNuke
DotNetNuke
 
How to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScriptHow to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScript
 
Virtual Environment and Web development using Django
Virtual Environment and Web development using DjangoVirtual Environment and Web development using Django
Virtual Environment and Web development using Django
 
Getting started with wxWidgets
Getting started with wxWidgets Getting started with wxWidgets
Getting started with wxWidgets
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
 
Mini Curso de Django
Mini Curso de DjangoMini Curso de Django
Mini Curso de Django
 
Django tutorial
Django tutorialDjango tutorial
Django tutorial
 
Django crush course
Django crush course Django crush course
Django crush course
 
Mvc4 crud operations.-kemuning senja
Mvc4 crud operations.-kemuning senjaMvc4 crud operations.-kemuning senja
Mvc4 crud operations.-kemuning senja
 
Collective.amberjack ploneconf2010
Collective.amberjack ploneconf2010Collective.amberjack ploneconf2010
Collective.amberjack ploneconf2010
 
Django
DjangoDjango
Django
 
Cis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry universityCis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry university
 
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
Decoupling Drupal mit dem Lupus Nuxt.js Drupal StackDecoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
 
BreizhBeans - Web components
BreizhBeans - Web componentsBreizhBeans - Web components
BreizhBeans - Web components
 
Download disabled slideshare ppts, Download from slideshare without login
Download disabled  slideshare ppts, Download from slideshare without loginDownload disabled  slideshare ppts, Download from slideshare without login
Download disabled slideshare ppts, Download from slideshare without login
 
MySQL document_store
MySQL document_storeMySQL document_store
MySQL document_store
 
Dolibarr - information for developers and partners - devcamp lyon 2019
Dolibarr - information for developers and partners - devcamp lyon 2019Dolibarr - information for developers and partners - devcamp lyon 2019
Dolibarr - information for developers and partners - devcamp lyon 2019
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 

Plus de David Nguyen

ACOMP_2014_submission_70
ACOMP_2014_submission_70ACOMP_2014_submission_70
ACOMP_2014_submission_70David Nguyen
 
Compressed js with NodeJS & GruntJS
Compressed js with NodeJS & GruntJSCompressed js with NodeJS & GruntJS
Compressed js with NodeJS & GruntJSDavid Nguyen
 
Chứng minh số node của Heap chiều cao h
Chứng minh số node của Heap chiều cao hChứng minh số node của Heap chiều cao h
Chứng minh số node của Heap chiều cao hDavid Nguyen
 
Hướng dẫn sử dụng Mind Manager 8
Hướng dẫn sử dụng Mind Manager 8 Hướng dẫn sử dụng Mind Manager 8
Hướng dẫn sử dụng Mind Manager 8 David Nguyen
 
KTMT Lý Thuyết Tổng Quát
KTMT Lý Thuyết Tổng QuátKTMT Lý Thuyết Tổng Quát
KTMT Lý Thuyết Tổng QuátDavid Nguyen
 
KTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm ĐộngKTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm ĐộngDavid Nguyen
 

Plus de David Nguyen (11)

ACOMP_2014_submission_70
ACOMP_2014_submission_70ACOMP_2014_submission_70
ACOMP_2014_submission_70
 
Compressed js with NodeJS & GruntJS
Compressed js with NodeJS & GruntJSCompressed js with NodeJS & GruntJS
Compressed js with NodeJS & GruntJS
 
Facebook API
Facebook APIFacebook API
Facebook API
 
Quick sort
Quick sortQuick sort
Quick sort
 
Merge sort
Merge sortMerge sort
Merge sort
 
Heap Sort
Heap SortHeap Sort
Heap Sort
 
Chứng minh số node của Heap chiều cao h
Chứng minh số node của Heap chiều cao hChứng minh số node của Heap chiều cao h
Chứng minh số node của Heap chiều cao h
 
Hướng dẫn sử dụng Mind Manager 8
Hướng dẫn sử dụng Mind Manager 8 Hướng dẫn sử dụng Mind Manager 8
Hướng dẫn sử dụng Mind Manager 8
 
KTMT Lý Thuyết Tổng Quát
KTMT Lý Thuyết Tổng QuátKTMT Lý Thuyết Tổng Quát
KTMT Lý Thuyết Tổng Quát
 
KTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm ĐộngKTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm Động
 
Mô Hình MVC 3.0
Mô Hình MVC 3.0Mô Hình MVC 3.0
Mô Hình MVC 3.0
 

Dernier

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 

Dernier (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

MVC4 – knockout.js – bootstrap – step by step – part 1

  • 1. Nguyễn Ngọc Dũng P a g e 1 | 28 https://nndung179.wordpress.com/ Contents O/ Things I do in this tutorial........................................................................................................................2 I/ Database ....................................................................................................................................................2 II/ Create New Project ..................................................................................................................................3 2.1/ Create New Project MVC4................................................................................................................3 2.2/ Add Controller + Add View ..............................................................................................................4 2.3/ Add Folder DTO + DAO...................................................................................................................6 2.3.1/ Add Database via LINQ TO SQL...............................................................................................6 2.3.2/ Add class handle data to DAO folder .......................................................................................10 2.3.3/ Create Stored Procedure for SELECT DATA ..........................................................................11 2.3.4/ Add Stored Procedure to StudentDB.dbml...............................................................................11 2.3.5/ Code handle Get List Student of DAO class.............................................................................12 2.3.6/ Add handle function to Controller ............................................................................................13 III/ Ajax + Knockout.js + Jquery ................................................................................................................13 3.1/ Change something in your layout ....................................................................................................14 3.2/ Create Folder contain Javascript file................................................................................................14 3.3/ Go to view Index + doing something...............................................................................................16 3.4/ Put some code to StudentJS.js .........................................................................................................17 3.4.1/ Create Object with Contructor..................................................................................................17 3.4.2/ Function to Get data..................................................................................................................18 3.4.3/ Create View Model with Knockout.js ......................................................................................18 3.4.4/ Update your View Index...........................................................................................................19 3.4.5/ Run............................................................................................................................................20 IV/ Bootstrap...............................................................................................................................................20 4.1/ Download and Install.......................................................................................................................20 4.2/ How to use .......................................................................................................................................24 4.3/ Run and feel cool .............................................................................................................................26 V/ Source Code...........................................................................................................................................28
  • 2. Nguyễn Ngọc Dũng P a g e 2 | 28 https://nndung179.wordpress.com/ MVC4 – knockout.js – Bootstrap – Step by Step – Part 1 Hello you guys. In this article. I’m going to show you how to use MVC4 and Ajax via KNOCKOUT.js. You guys just follow step by step of this article. In the Part 1 => Just Interface and Select student O/ Things I do in this tutorial + MVC 4 – Microsoft + knockout.js + Jquery + Bootstrap + Microsoft SQL + Stored Procedure => Enjoy your meal :) I/ Database
  • 3. Nguyễn Ngọc Dũng P a g e 3 | 28 https://nndung179.wordpress.com/ II/ Create New Project 2.1/ Create New Project MVC4 click OK to create new Project
  • 4. Nguyễn Ngọc Dũng P a g e 4 | 28 https://nndung179.wordpress.com/ 2.2/ Add Controller + Add View I name this controller “Home” And then I add view for this HomeController
  • 5. Nguyễn Ngọc Dũng P a g e 5 | 28 https://nndung179.wordpress.com/ I use the default layout of this template
  • 6. Nguyễn Ngọc Dũng P a g e 6 | 28 https://nndung179.wordpress.com/ 2.3/ Add Folder DTO + DAO DTO: Contain Database and object DAO: Handle database (select, insert, update) In folder Models => I create DTO and DAO folder 2.3.1/ Add Database via LINQ TO SQL Right click on folder DTO => Add => New Item Choose Data => LINQ to SQL Classes => Name it “StudentDB.dbml”
  • 7. Nguyễn Ngọc Dũng P a g e 7 | 28 https://nndung179.wordpress.com/ The result we get from image above is a blank screen. Next thing, we’re going to do is: + add connection from Server Explorer to the database + Drag database from Server Explorer to StudentDB.dbml
  • 8. Nguyễn Ngọc Dũng P a g e 8 | 28 https://nndung179.wordpress.com/
  • 9. Nguyễn Ngọc Dũng P a g e 9 | 28 https://nndung179.wordpress.com/ Just Drag this table to left pane of StudenDB.dbml
  • 10. Nguyễn Ngọc Dũng P a g e 10 | 28 https://nndung179.wordpress.com/ 2.3.2/ Add class handle data to DAO folder Do following things like me
  • 11. Nguyễn Ngọc Dũng P a g e 11 | 28 https://nndung179.wordpress.com/ 2.3.3/ Create Stored Procedure for SELECT DATA 2.3.4/ Add Stored Procedure to StudentDB.dbml + Go to Server explorer => Expand folder Stored Procedure Folder. You’ll see the stored you’ve just created
  • 12. Nguyễn Ngọc Dũng P a g e 12 | 28 https://nndung179.wordpress.com/ + Just Drag this stored to your Right Pane of StudentDB.dbml + Save it via (Ctrl + S) 2.3.5/ Code handle Get List Student of DAO class Go to StudentDAO.cs and take this code to select the list of student. Of course, you can create your own function
  • 13. Nguyễn Ngọc Dũng P a g e 13 | 28 https://nndung179.wordpress.com/ 2.3.6/ Add handle function to Controller III/ Ajax + Knockout.js + Jquery
  • 14. Nguyễn Ngọc Dũng P a g e 14 | 28 https://nndung179.wordpress.com/ 3.1/ Change something in your layout Go to Shared => _Layout.cshtml => Change something as follow I added 2 section to this layout. + David_Custom_CSS: to insert your custom link css + David_Custom_Scripts: to Insert your custom js link 3.2/ Create Folder contain Javascript file + Add folder and name it “My Script”
  • 15. Nguyễn Ngọc Dũng P a g e 15 | 28 https://nndung179.wordpress.com/ + Add javascript file to Folder “My Script” and name this javascript file “StudentJS.js“
  • 16. Nguyễn Ngọc Dũng P a g e 16 | 28 https://nndung179.wordpress.com/ 3.3/ Go to view Index + doing something In this section, you must add the link to reference to related .js file and .css file
  • 17. Nguyễn Ngọc Dũng P a g e 17 | 28 https://nndung179.wordpress.com/ 3.4/ Put some code to StudentJS.js 3.4.1/ Create Object with Contructor If you don’t understand this code. You just go to GOOGLE => Search “Object In Javascript“. I’m not going to explain this to you. Because it’s out of this article.
  • 18. Nguyễn Ngọc Dũng P a g e 18 | 28 https://nndung179.wordpress.com/ 3.4.2/ Function to Get data I used ajax of Jquery to call the method in controller to recieve the data and store it in array that I’m going to create in the model in next step. 3.4.3/ Create View Model with Knockout.js You can figure how knockout.js work in this link: http://knockoutjs.com/
  • 19. Nguyễn Ngọc Dũng P a g e 19 | 28 https://nndung179.wordpress.com/ 3.4.4/ Update your View Index
  • 20. Nguyễn Ngọc Dũng P a g e 20 | 28 https://nndung179.wordpress.com/ 3.4.5/ Run + It worked, but it is so ugly. IV/ Bootstrap If you’re really want to get a good interface. I recommend bootstrap. 4.1/ Download and Install + First, You need to access the link: http://getbootstrap.com/
  • 21. Nguyễn Ngọc Dũng P a g e 21 | 28 https://nndung179.wordpress.com/ + Download this. And you’ll get this
  • 22. Nguyễn Ngọc Dũng P a g e 22 | 28 https://nndung179.wordpress.com/ + Extract it, and go to this folder, and copy all files + Create Folder of Project, and name it “Bootstrap“
  • 23. Nguyễn Ngọc Dũng P a g e 23 | 28 https://nndung179.wordpress.com/ + Parse all file you’ve just copied from bootstrap folder + Expand all folder contain in “Bootstrap“. Place the link like below
  • 24. Nguyễn Ngọc Dũng P a g e 24 | 28 https://nndung179.wordpress.com/ 4.2/ How to use Access like image below: + Go to table
  • 25. Nguyễn Ngọc Dũng P a g e 25 | 28 https://nndung179.wordpress.com/ + You now see much more example for using class of bootstrap. I’m going to choose one + I choose “table table hover“. I must update my View Index like this.
  • 26. Nguyễn Ngọc Dũng P a g e 26 | 28 https://nndung179.wordpress.com/ 4.3/ Run and feel cool + The problem is the button is so ugly. I want it to be nice and cool. Like prior index. We choose button instead table + It’s going to show you like below
  • 27. Nguyễn Ngọc Dũng P a g e 27 | 28 https://nndung179.wordpress.com/ + See examples and do like this + Ok let’s update the View Index again
  • 28. Nguyễn Ngọc Dũng P a g e 28 | 28 https://nndung179.wordpress.com/ + Run again and enjoy the tutorial :) V/ Source Code http://www.mediafire.com/download/jbua22nv4ekljk6/Knockout_1.rar