You are on page 1of 8

FPT Aptech

ASP.NET 4.5 -Lab 3

ASP.NET 4.5 Assignment Guide


Introduction : Developing a ASP.NET application using Model Binder & Model Validation Requirement : Visual Studio .Net 2012 (.Net Framework 4.5 ) In SQL Server 2008 / 2012 , create a database named Manager and create a table named Books as the following :

Step 1 : Create ASP.NET Application 1.1 From menu File|New Web Site, In Project Type | Visual C# & Templates | ASP.NET Empty Web Site and named MyWebApp , add App_Code folder. 1.2 Right-click on MyWebApp | Add New Item | ADO.NET Entity Data Model , named BookManager.edmx as the below figure .

kiemhh@fpt.com.vn

Page:1

FPT Aptech -

ASP.NET 4.5 -Lab 3

Microsoft Visual Studio dialog showed , click Yes to add model into App_Code .

In Entity Data Model Wizard dialog , select Generate from database , click Next | New Connection , and configure as the below figures :

kiemhh@fpt.com.vn

Page:2

FPT Aptech

ASP.NET 4.5 -Lab 3

kiemhh@fpt.com.vn

Page:3

FPT Aptech

ASP.NET 4.5 -Lab 3

kiemhh@fpt.com.vn

Page:4

FPT Aptech

ASP.NET 4.5 -Lab 3

Step 2 :Create a ASP.NET page 2.1 Add new a ASP.NET MaintainBooks.aspx with interface as the below table: named user

Control Type TextBox TextBox TextBox Validation Summary ID ID ID

Properties/ Event txtBookID txtBookTitle txtBookPrice Red

Value

ForeColor HeaderText ID ItemType

Please check the following errors: fvProductDetail Book Insert fvProductDetail_InsertBook Reference to HTML Code for FormView gvBookList BookID True True gvBookList_GetBooks gvBookList_UpdateBook gvBookList_DeleteBook

FormView

DefaultMode InsertMethod Design for InsertItemTemplate ID DataKeyNames AutoGenerateDeleteButton

GridView

AutoGenerateEditButton SelectMethod UpdateMethod DeleteMethod

kiemhh@fpt.com.vn

Page:5

FPT Aptech HTML Code for FormView

ASP.NET 4.5 -Lab 3

2.2 Right-click on App_Code | Add | Class , named Book.cs and writes code as the following:

kiemhh@fpt.com.vn

Page:6

FPT Aptech

ASP.NET 4.5 -Lab 3

2.3 Double click on the MaintainBooks.aspx page and writes code for MaintainBooks.aspx.cs file as the following :

Step 3 : Run MyWebApp application On the MyWebApp project , select MaintainBooks .aspx , right-click | View in Browser ,
and test functions as the below figure .

kiemhh@fpt.com.vn

Page:7

FPT Aptech

ASP.NET 4.5 -Lab 3

kiemhh@fpt.com.vn

Page:8

You might also like