AngularJs Table With WebForms
AngularJs Table With WebForms
AngularJs Table With WebForms
Introduction
In this article i am going to explain how you can use angular js table with bootstrap 4 in asp.net web form, and also show you how you can display records in tabular format using angular js and bootstrap 4 in asp.net as well as how you can
create master page and use created master page within all child page in asp.net.
In my previous article i explained how you can upload file using Angular Js and also explained basic CURD operation with WEB API Using AngularJs in Asp.Net MVC Application.
When you working with any data driven web applications sometime as per client requirement you need to fetch data from database using stored procedure/inline sql statement or any json data and display all the records in grid, here grid is
just like table nothing else. here i'll show you how you can create simple html table and display record in html table instead of data grid.
Toady, while i working on my project i got requirement to create report for employee using angular js and based on report give yearly reward to employee based on month wise employee performance. where i need to use Angular Js Table
and i think this requirement i should share with you with an example, this may helps you to build a web page in asp.net using Angular Js.
Hear i will change something from my actual requirement and show you only basic columns of employee table with sample data for demonstration and just show how you can create and use Angular Js Table and how you can use
bootstrap 4 in your web application.
Requirement
https://coding-vila.blogspot.com/2018/12/angularjs-table-with-bootstrap-4-in-asp-dot-net-web-forms.html 1/8
28/8/2019 AngularJs Table with Bootstrap 4 in ASP.NET Web Forms - Codingvila
Implementation
Let's Create a basic demonstration to archive given requirement, So you need to follow some steps described as below.
Step 2 : Click on top menu "File" >> "New" >> "Web Site".
Step 3 : Now You can see popup on your screen shown as below where select your language and select Asp.net Web Forms Site then choose path where you want to save your project and press OK.
https://coding-vila.blogspot.com/2018/12/angularjs-table-with-bootstrap-4-in-asp-dot-net-web-forms.html 2/8
28/8/2019 AngularJs Table with Bootstrap 4 in ASP.NET Web Forms - Codingvila
Add caption
Step 4 : After that Just Remove/modify other forms as per your need, hear i 'll remove all the forms instead of Default.aspx and site.master form.
App Folder
Step 7 : Write Script file for Employee data within "App" Folder
https://coding-vila.blogspot.com/2018/12/angularjs-table-with-bootstrap-4-in-asp-dot-net-web-forms.html 3/8
28/8/2019 AngularJs Table with Bootstrap 4 in ASP.NET Web Forms - Codingvila
app.value('EmployeeData', [
{ EmpCode: 18001, EmpName: 'Nikunj Satasiya', Joining: '05-05-2017', Department: 'Information Technology', Designation: 'Sr.Software Engineer', Salary: '42000' },
{ EmpCode: 18002, EmpName: 'Hiren Dobariya', Joining: '01-01-2017', Department: 'Information Technology', Designation: 'Sr.Software Engineer', Salary: '49000' },
{ EmpCode: 18003, EmpName: 'Vivek Ghadiya', Joining: '07-03-2017', Department: 'Information Technology', Designation: 'Web Developer', Salary: '22000' },
{ EmpCode: 18004, EmpName: 'Pratik Pansuriya', Joining: '12-08-2017', Department: 'Information Technology', Designation: 'Web Designer', Salary: '22000' },
{ EmpCode: 18005, EmpName: 'Sneha Patel', Joining: '09-04-2018', Department: 'Sales', Designation: 'Sr.Sales Executive', Salary: '33000' },
{ EmpCode: 18006, EmpName: 'Kishan Borad', Joining: '08-09-2012', Department: 'Information Technology', Designation: 'Software Engineer', Salary: '18000' },
{ EmpCode: 18007, EmpName: 'Vishwa Patel', Joining: '08-12-2013', Department: 'Technical Support', Designation: 'Support Executive', Salary: '25000' },
{ EmpCode: 18008, EmpName: 'Sarah Demola', Joining: '24-05-2017', Department: 'Technical Support', Designation: 'Support Executive', Salary: '25000' },
{ EmpCode: 18009, EmpName: 'Shruti Patel', Joining: '08-04-2014', Department: 'Network Security', Designation: 'Network Engineer', Salary: '17000' },
{ EmpCode: 18010, EmpName: 'Krishna Desai ', Joining: '15-09-2017', Department: 'Sales', Designation: 'Sr.Sales Executive', Salary: '36000' },
{ EmpCode: 18011, EmpName: 'Pravin Patel', Joining: '18-12-2018', Department: 'Sales', Designation: 'Sales Executive', Salary: '22000' },
{ EmpCode: 18012, EmpName: 'Milan Lathiya', Joining: '21-02-2016', Department: 'Technical Support', Designation: 'Support Executive', Salary: '29000' },
{ EmpCode: 18013, EmpName: 'Jigar Patel', Joining: '25-09-2017', Department: 'Network Security', Designation: 'Sr.Network Engineer', Salary: '39000' },
{ EmpCode: 18014, EmpName: 'Jhon Martin', Joining: '13-06-2015', Department: 'Information Technology', Designation: 'Sr.Web Developer', Salary: '40000' },
{ EmpCode: 18015, EmpName: 'Vikash Modi', Joining: '27-11-2017', Department: 'Network Security', Designation: 'Network Engineer', Salary: '21000' }
]);
Step 8 : Write Script file for angular controller within "App" Folder.
Anguler Js Script
Step 9 : Now, I'll design master page for default layout as per given requirement, hear you can design/modify your own layouts as per your need using CSS(cascading style sheet) or css class of bootstrap 4.
Here i will use bootstrap 4 for design my layout so first i will open my master page and link following CSS before end <head> tag.
CSS
Master Page
Site.Master
https://coding-vila.blogspot.com/2018/12/angularjs-table-with-bootstrap-4-in-asp-dot-net-web-forms.html 4/8
28/8/2019 AngularJs Table with Bootstrap 4 in ASP.NET Web Forms - Codingvila
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</div>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
<script src="scripts/jquery-1.9.1.js"></script>
<script src="scripts/bootstrap.js"></script>
<script src="scripts/angular.js"></script>
<script src="scripts/angular-resource.min.js"></script>
<script src="scripts/app/app.js"></script>
<script src="scripts/app/data.js"></script>
<script src="scripts/app/EmployeeController.js"></script>
</body>
</html>
If You analysed this master page then there i have linked my CSS and also assign reference of created module, data and angular controller as well as required script of AngularJs before end <body> tag..
AngularJS Script
<script src="scripts/jquery-1.9.1.js"></script>
<script src="scripts/bootstrap.js"></script>
<script src="scripts/angular.js"></script>
<script src="scripts/angular-resource.min.js"></script>
<script src="scripts/app/app.js"></script>
<script src="scripts/app/data.js"></script>
<script src="scripts/app/EmployeeController.js"></script>
There where you can see ContentPlaceHolder that is used to define a content region for a master page, signal master page may can have one or more ContentPlaceHolder controls.
Step 10 :Now, we will design our Default.aspx page, hear in between ContentPlaceHolder i will write following code to design html table using AngularJS and Bootstrap 4.
Default.aspx
https://coding-vila.blogspot.com/2018/12/angularjs-table-with-bootstrap-4-in-asp-dot-net-web-forms.html 6/8
28/8/2019 AngularJs Table with Bootstrap 4 in ASP.NET Web Forms - Codingvila
<th scope="col">Designation</th>
<th scope="col">Salary</th>
</tr>
</thead>
If You analysed this aspx page then i have created table and to display records of employee i have used directive ng-repeat and ng-repeat directive is perfect for displaying a html table. i have also used directive ng-app and it's described
as the root element of the AngularJS application as well as i also used directive ng-controller and that defins a controller in AngularJs Application there where ng-controller="EmployeeController" is an AngularJS directive. In AngularJS
controller invoke with a $scope object where $scope is application object.
Hear you also can use order by as per your need, you just need to use following code.
https://coding-vila.blogspot.com/2018/12/angularjs-table-with-bootstrap-4-in-asp-dot-net-web-forms.html 7/8
28/8/2019 AngularJs Table with Bootstrap 4 in ASP.NET Web Forms - Codingvila
</td>
</tr>
</table>
If you wants to display all the records with uppercase filter then you can do you just need to follow this rule.
https://coding-vila.blogspot.com/2018/12/angularjs-table-with-bootstrap-4-in-asp-dot-net-web-forms.html 8/8