intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Phát triển ứng dụng web nâng cao với ASP.net - Part 1

Chia sẻ: Huongdanhoctot Huongdanhoctot | Ngày: | Loại File: PDF | Số trang:22

92
lượt xem
22
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Tài liệu giảng dạy về ASP.net đã được giảng dạy với mục đích cung cấp cho sinh viên những kiến thức cơ bản nhất, có tính hệ thống liên quan tới lập trình. Thông qua cuốn tài liệu này, chúng tôi muốn giới thiệu với các bạn đọc về kỹ năng lập trình cơ bản.Mời các bạn cùng tham khảo

Chủ đề:
Lưu

Nội dung Text: Phát triển ứng dụng web nâng cao với ASP.net - Part 1

  1. TRƯ NG Đ I H C KHOA H C T NHIÊN KHOA CÔNG NGH THÔNG TIN B MÔN CÔNG NGH PH N M M --- --- Product Catalog – P2 Môn h c: Phát tri n ng d ng Web nâng cao v i ASP.NET 1 1 Nguy n Ph m Phương Nam - B môn CNPM – Khoa CNTT - DHKHTN
  2. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 1 Xây dưng thành phần Data Tier 1.1 Tạo các Data Table 1.1.1 Category USE BalloonShop GO CREATE TABLE Category( CategoryID INT IDENTITY(1,1) NOT NULL, DepartmentID INT NOT NULL, Name NVARCHAR(50) NOT NULL, Description NVARCHAR(1000) NULL, CONSTRAINT PK_Category_1 PRIMARY KEY CLUSTERED(CategoryID ASC) ) GO ALTER TABLE Category ADD CONSTRAINT FK_Category_Department FOREIGN KEY(DepartmentID) REFERENCES Department (DepartmentID) GO USE BalloonShop GO TRUNCATE TABLE Category GO SET IDENTITY_INSERT Category ON GO INSERT INTO Category (CategoryID, DepartmentID, Name, Description ) VALUES (1, 1, 'Love & Romance', 'Here''s our collection of balloons with romantic messages.') INSERT INTO Category (CategoryID, DepartmentID, Name, Description ) VALUES (2, 1, 'Birthdays', 'Tell someone "Happy Birthday" with one of these wonderful balloons!') INSERT INTO Category (CategoryID, DepartmentID, Name, Description ) VALUES (3, 1, 'Weddings', 'Going to a wedding? Here''s a collection of balloons for that special event!') INSERT INTO Category (CategoryID, DepartmentID, Name, Description ) VALUES (4, 2, 'Message Balloons', 'Why write on paper, when you can deliver your message on a balloon?') 2 Tr n Phư ng Hoàng – PTN BMCNPM – Khoa CNTT – DHKHTN
  3. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 INSERT INTO Category (CategoryID, DepartmentID, Name, Description ) VALUES (5, 2, 'Cartoons', 'Buy a balloon with your child''s favorite cartoon character!') INSERT INTO Category (CategoryID, DepartmentID, Name, Description ) VALUES (6, 2, 'Miscellaneous', 'Various baloons that your kid will most certainly love!') GO SET IDENTITY_INSERT Category OFF GO 1.1.2 Product USE BalloonShop GO CREATE TABLE Product( ProductID INT IDENTITY(1,1) NOT NULL, Name NVARCHAR(50) NOT NULL, Description NVARCHAR(MAX) NOT NULL, Price MONEY NOT NULL, Image1FileName NVARCHAR(50) NULL, Image2FileName NVARCHAR(50) NULL, OnCatalogPromotion BIT NOT NULL, OnDepartmentPromotion BIT NOT NULL, CONSTRAINT PK_Product PRIMARY KEY CLUSTERED (ProductID ASC) ) USE BalloonShop GO TRUNCATE TABLE Product GO SET IDENTITY_INSERT Product ON GO INSERT INTO Product(ProductID, Name, Description, Price, Image1FileName, Image2FileName, OnCatalogPromotion, OnDepartmentPromotion ) VALUES (1, 'I Love You (Simon Elvin)', 'An adorable romantic balloon by Simon Elvin. You''ll fall in love with the cute bear bearing a bouquet of roses, a heart with I Love You, and a card.', 121.9900, 't0326801.jpg', '0326801.jpg', 0, 1) GO 3 Nguy n Ph m Phương Nam - B môn CNPM – Khoa CNTT - DHKHTN
  4. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 Ghi chú: S d ng các file script ư c cung c p s n to y CSDL 1.1.3 ProductCategory USE BalloonShop GO CREATE TABLE ProductCategory( ProductID INT NOT NULL, CategoryID INT NOT NULL, CONSTRAINT PK_ProductCategory PRIMARY KEY CLUSTERED (ProductID ASC, CategoryID ASC) ) GO ALTER TABLE ProductCategory WITH CHECK ADD CONSTRAINT FK_ProductCategory_Category FOREIGN KEY(CategoryID) REFERENCES Category (CategoryID) GO ALTER TABLE ProductCategory WITH CHECK ADD CONSTRAINT FK_ProductCategory_Product FOREIGN KEY(ProductID) REFERENCES Product (ProductID) USE BalloonShop GO INSERT INTO ProductCategory(ProductID, CategoryID) VALUES(1, 1) GO 1.2 Thành phần Store Procedure - Ý nghĩa ? - Input và Output parameter USE BalloonShop GO CREATE PROCEDURE GetDepartmentDetails (@DepartmentID INT) AS SELECT Name, Description FROM Department WHERE DepartmentID = @DepartmentID 4 Tr n Phư ng Hoàng – PTN BMCNPM – Khoa CNTT – DHKHTN
  5. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 GO CREATE PROCEDURE GetCategoryDetails (@CategoryID INT) AS SELECT DepartmentID, Name, Description FROM Category WHERE CategoryID = @CategoryID GO CREATE PROCEDURE GetProductDetails (@ProductID INT) AS SELECT Name, Description, Price, Image1FileName, Image2FileName, OnCatalogPromotion, OnDepartmentPromotion FROM Product WHERE ProductID = @ProductID GO CREATE PROCEDURE GetCategoriesInDepartment (@DepartmentID INT) AS SELECT CategoryID, Name, Description FROM Category WHERE DepartmentID = @DepartmentID GO CREATE PROCEDURE GetProductsOnCatalogPromotion (@DescriptionLength INT, @PageNumber INT, @ProductsPerPage INT, @HowManyProducts INT OUTPUT) AS -- declare a new TABLE variable DECLARE @Products TABLE (RowNumber INT, ProductID INT, Name NVARCHAR(50), Description NVARCHAR(MAX), Price MONEY, Image1FileName NVARCHAR(50), Image2FileName NVARCHAR(50), OnCatalogPromotion bit, OnDepartmentPromotion bit) -- populate the table variable with the complete list of products INSERT INTO @Products SELECT ROW_NUMBER() OVER (ORDER BY Product.ProductID), ProductID, Name, 5 Nguy n Ph m Phương Nam - B môn CNPM – Khoa CNTT - DHKHTN
  6. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 CASE WHEN LEN(Description) (@PageNumber - 1) * @ProductsPerPage AND RowNumber
  7. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 SELECT ProductID, Name, Description, Price, Image1FileName, Image2FileName, OnCatalogPromotion, OnDepartmentPromotion FROM @Products WHERE RowNumber > (@PageNumber - 1) * @ProductsPerPage AND RowNumber
  8. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 -- extract the requested page of products SELECT ProductID, Name, Description, Price, Image1FileName, Image2FileName, OnCatalogPromotion, OnDepartmentPromotion FROM @Products WHERE RowNumber > (@PageNumber - 1) * @ProductsPerPage AND RowNumber
  9. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 static BalloonShopConfiguration() { dbConnectionString = ConfigurationManager.ConnectionStrings["BalloonShopConnection"].ConnectionStr ing; dbProviderName = ConfigurationManager.ConnectionStrings["BalloonShopConnection"].ProviderName; productsPerPage = Int32.Parse(ConfigurationManager.AppSettings["ProductsPerPage"].ToString()); productDescriptionLength = Int32.Parse(ConfigurationManager.AppSettings["ProductDescriptionLength"].ToSt ring()); } 2.3 CatalogAccess class - Thêm và thay i m t s thành ph n 2.3.1 DepartmentDetails - Thêm thành ph n struct DepartmentDetails using System; using System.Data; using System.Data.Common; /// /// Summary description for CatalogAccess /// /// public struct DepartmentDetails { public string Name; public string Description; } public static class CatalogAccess { static CatalogAccess() { } } 9 Nguy n Ph m Phương Nam - B môn CNPM – Khoa CNTT - DHKHTN
  10. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 - Thêm method (hàm) GetDepartmentDetails public static DepartmentDetails GetDepartmentDetails(string departmentId) { // get a configured DbCommand object DbCommand comm = GenericDataAccess.CreateCommand(); // set the stored procedure name comm.CommandText = "GetDepartmentDetails"; // create a new parameter DbParameter param = comm.CreateParameter(); param.ParameterName = "@DepartmentID"; param.Value = departmentId; param.DbType = DbType.Int32; comm.Parameters.Add(param); // execute the stored procedure DataTable table = GenericDataAccess.ExecuteSelectCommand(comm); // wrap retrieved data into a DepartmentDetails object DepartmentDetails details = new DepartmentDetails(); if (table.Rows.Count > 0) { details.Name = table.Rows[0]["Name"].ToString(); details.Description = table.Rows[0]["Description"].ToString(); } // return department details return details; } 2.3.2 CategoryDetails - Thêm thành ph n struct CategoryDetails public struct CategoryDetails { public int DepartmentId; public string Name; public string Description; } - Thêm method (hàm) GetCategoryDetails public static CategoryDetails GetCategoryDetails(string categoryId) { // get a configured DbCommand object DbCommand comm = GenericDataAccess.CreateCommand(); // set the stored procedure name comm.CommandText = "GetCategoryDetails"; // create a new parameter DbParameter param = comm.CreateParameter(); param.ParameterName = "@CategoryID"; param.Value = categoryId; param.DbType = DbType.Int32; 10 Tr n Phư ng Hoàng – PTN BMCNPM – Khoa CNTT – DHKHTN
  11. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 comm.Parameters.Add(param); // execute the stored procedure DataTable table = GenericDataAccess.ExecuteSelectCommand(comm); // wrap retrieved data into a CategoryDetails object CategoryDetails details = new CategoryDetails(); if (table.Rows.Count > 0) { details.DepartmentId = Int32.Parse(table.Rows[0]["DepartmentID"].ToString()); details.Name = table.Rows[0]["Name"].ToString(); details.Description = table.Rows[0]["Description"].ToString(); } // return department details return details; } 2.3.3 ProductDetails - Thêm thành ph n struct ProductDetails public struct ProductDetails { public string Name; public string Description; public decimal Price; public string Image1FileName; public string Image2FileName; public bool OnDepartmentPromotion; public bool OnCatalogPromotion; } - Thêm method (hàm) GetProductDetails public static ProductDetails GetProductDetails(string productId) { // get a configured DbCommand object DbCommand comm = GenericDataAccess.CreateCommand(); // set the stored procedure name comm.CommandText = "GetProductDetails"; // create a new parameter DbParameter param = comm.CreateParameter(); param.ParameterName = "@ProductID"; param.Value = productId; param.DbType = DbType.Int32; comm.Parameters.Add(param); // execute the stored procedure DataTable table = GenericDataAccess.ExecuteSelectCommand(comm); // wrap retrieved data into a ProductDetails object ProductDetails details = new ProductDetails(); if (table.Rows.Count > 0) { // get the first table row 11 Nguy n Ph m Phương Nam - B môn CNPM – Khoa CNTT - DHKHTN
  12. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 DataRow dr = table.Rows[0]; // get product details details.Name = dr["Name"].ToString(); details.Description = dr["Description"].ToString(); details.Price = Decimal.Parse(dr["Price"].ToString()); details.Image1FileName = dr["Image1FileName"].ToString(); details.Image2FileName = dr["Image2FileName"].ToString(); details.OnDepartmentPromotion = bool.Parse(dr["OnDepartmentPromotion"].ToString()); details.OnCatalogPromotion = bool.Parse(dr["OnCatalogPromotion"].ToString()); } // return department details return details; } 2.3.4 Mở rộng - Thêm method (hàm) GetCategoryinDepartment public static DataTable GetCategoriesInDepartment(string departmentId) { // get a configured DbCommand object DbCommand comm = GenericDataAccess.CreateCommand(); // set the stored procedure name comm.CommandText = "GetCategoriesInDepartment"; // create a new parameter DbParameter param = comm.CreateParameter(); param.ParameterName = "@DepartmentID"; param.Value = departmentId; param.DbType = DbType.Int32; comm.Parameters.Add(param); // execute the stored procedure return GenericDataAccess.ExecuteSelectCommand(comm); } - Thêm method (hàm) GetProductsOnCatalogPromotion public static DataTable GetProductsOnCatalogPromotion(string pageNumber, out int howManyPages) { // get a configured DbCommand object DbCommand comm = GenericDataAccess.CreateCommand(); // set the stored procedure name comm.CommandText = "GetProductsOnCatalogPromotion"; // create a new parameter DbParameter param = comm.CreateParameter(); param.ParameterName = "@DescriptionLength"; param.Value = BalloonShopConfiguration.ProductDescriptionLength; param.DbType = DbType.Int32; comm.Parameters.Add(param); // create a new parameter param = comm.CreateParameter(); param.ParameterName = "@PageNumber"; param.Value = pageNumber; 12 Tr n Phư ng Hoàng – PTN BMCNPM – Khoa CNTT – DHKHTN
  13. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 param.DbType = DbType.Int32; comm.Parameters.Add(param); // create a new parameter param = comm.CreateParameter(); param.ParameterName = "@ProductsPerPage"; param.Value = BalloonShopConfiguration.ProductsPerPage; param.DbType = DbType.Int32; comm.Parameters.Add(param); // create a new parameter param = comm.CreateParameter(); param.ParameterName = "@HowManyProducts"; param.Direction = ParameterDirection.Output; param.DbType = DbType.Int32; comm.Parameters.Add(param); // execute the stored procedure and save the results in a DataTable DataTable table = GenericDataAccess.ExecuteSelectCommand(comm); // calculate how many pages of products and set the out parameter int howManyProducts = Int32.Parse(comm.Parameters ["@HowManyProducts"].Value.ToString()); howManyPages = (int)Math.Ceiling((double)howManyProducts / (double)BalloonShopConfiguration.ProductsPerPage); // return the page of products return table; } - Thêm method (hàm) GetProductsOnCatalogPromotion public static DataTable GetProductsOnDepartmentPromotion (string departmentId, string pageNumber, out int howManyPages) { // get a configured DbCommand object DbCommand comm = GenericDataAccess.CreateCommand(); // set the stored procedure name comm.CommandText = "GetProductsOnDepartmentPromotion"; // create a new parameter DbParameter param = comm.CreateParameter(); param.ParameterName = "@DepartmentID"; param.Value = departmentId; param.DbType = DbType.Int32; comm.Parameters.Add(param); // create a new parameter param = comm.CreateParameter(); param.ParameterName = "@DescriptionLength"; param.Value = BalloonShopConfiguration.ProductDescriptionLength; param.DbType = DbType.Int32; comm.Parameters.Add(param); // create a new parameter param = comm.CreateParameter(); param.ParameterName = "@PageNumber"; param.Value = pageNumber; param.DbType = DbType.Int32; comm.Parameters.Add(param); // create a new parameter param = comm.CreateParameter(); 13 Nguy n Ph m Phương Nam - B môn CNPM – Khoa CNTT - DHKHTN
  14. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 param.ParameterName = "@ProductsPerPage"; param.Value = BalloonShopConfiguration.ProductsPerPage; param.DbType = DbType.Int32; comm.Parameters.Add(param); // create a new parameter param = comm.CreateParameter(); param.ParameterName = "@HowManyProducts"; param.Direction = ParameterDirection.Output; param.DbType = DbType.Int32; comm.Parameters.Add(param); // execute the stored procedure and save the results in a DataTable DataTable table = GenericDataAccess.ExecuteSelectCommand(comm); // calculate how many pages of products and set the out parameter int howManyProducts = Int32.Parse (comm.Parameters["@HowManyProducts"].Value.ToString()); howManyPages = (int)Math.Ceiling((double)howManyProducts / (double)BalloonShopConfiguration.ProductsPerPage); // return the page of products return table; } - Thêm method (hàm) GetProductsInCategory public static DataTable GetProductsInCategory (string categoryId, string pageNumber, out int howManyPages) { // get a configured DbCommand object DbCommand comm = GenericDataAccess.CreateCommand(); // set the stored procedure name comm.CommandText = "GetProductsInCategory"; // create a new parameter DbParameter param = comm.CreateParameter(); param.ParameterName = "@CategoryID"; param.Value = categoryId; param.DbType = DbType.Int32; comm.Parameters.Add(param); // create a new parameter param = comm.CreateParameter(); param.ParameterName = "@DescriptionLength"; param.Value = BalloonShopConfiguration.ProductDescriptionLength; param.DbType = DbType.Int32; comm.Parameters.Add(param); // create a new parameter param = comm.CreateParameter(); param.ParameterName = "@PageNumber"; param.Value = pageNumber; param.DbType = DbType.Int32; comm.Parameters.Add(param); // create a new parameter param = comm.CreateParameter(); param.ParameterName = "@ProductsPerPage"; param.Value = BalloonShopConfiguration.ProductsPerPage; param.DbType = DbType.Int32; 14 Tr n Phư ng Hoàng – PTN BMCNPM – Khoa CNTT – DHKHTN
  15. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 comm.Parameters.Add(param); // create a new parameter param = comm.CreateParameter(); param.ParameterName = "@HowManyProducts"; param.Direction = ParameterDirection.Output; param.DbType = DbType.Int32; comm.Parameters.Add(param); // execute the stored procedure and save the results in a DataTable DataTable table = GenericDataAccess.ExecuteSelectCommand(comm); // calculate how many pages of products and set the out parameter int howManyProducts = Int32.Parse (comm.Parameters["@HowManyProducts"].Value.ToString()); howManyPages = (int)Math.Ceiling((double)howManyProducts / (double)BalloonShopConfiguration.ProductsPerPage); // return the page of products return table; } 3 Xây dựng thành phần Presentation Tier 3.1 List of Categories - T o User Control CategoriesList.ascx - Thành ph n GUI - Thành ph n code protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string departmentId = Request.QueryString["DepartmentID"]; 15 Nguy n Ph m Phương Nam - B môn CNPM – Khoa CNTT - DHKHTN
  16. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 if (departmentId != null) { DataTable dt = CatalogAccess.GetCategoriesInDepartment(departmentId); string categoryID = Request.QueryString["CategoryID"]; if (!string.IsNullOrEmpty(categoryID)) { for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["CategoryID"].ToString() == categoryID) { dt.Rows[i]["Name"] = "" + dt.Rows[i]["Name"] + ""; } } } list.DataSource = dt; list.DataBind(); } else { this.Visible = false; } } } - Thêm thành ph n CategoriesList.ascx vào thành ph n DepartmentsList.ascx (th c hi n theo hư ng d n) o Kéo th o X lý hàm s ki n ItemDataBound protected void list_ItemDataBound(object sender, DataListItemEventArgs e) { if (string.IsNullOrEmpty(Request.QueryString["DepartmentID"]) || (e.Item.FindControl("hdf_DepartmentID") as HiddenField).Value.ToString() != Request.QueryString["DepartmentID"]) { e.Item.FindControl("CategoriesList1").Visible = false; } } - T o trang Catalog.aspx và test project 16 Tr n Phư ng Hoàng – PTN BMCNPM – Khoa CNTT – DHKHTN
  17. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 3.2 List of Products - T o User Control ProductsList.ascx - Thành ph n GUI &nbsp;&nbsp; Previous &nbsp;&nbsp; Next Price: - Thành ph n code using System; using System.Collections; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; 17 Nguy n Ph m Phương Nam - B môn CNPM – Khoa CNTT - DHKHTN
  18. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Collections.Specialized; public partial class UserControls_ProductsList : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { PopulateControls(); } private void PopulateControls() { // Retrieve DepartmentID from the query string string departmentId = Request.QueryString["DepartmentID"]; // Retrieve CategoryID from the query string string categoryId = Request.QueryString["CategoryID"]; // Retrieve Page from the query string string page = Request.QueryString["Page"]; if (page == null) page = "1"; // How many pages of products? int howManyPages = 1; // If browsing a category... if (categoryId != null) { // Retrieve list of products in a category list.DataSource = CatalogAccess.GetProductsInCategory(categoryId, page, out howManyPages); list.DataBind(); } else if (departmentId != null) { // Retrieve list of products on department promotion list.DataSource = CatalogAccess.GetProductsOnDepartmentPromotion (departmentId, page, out howManyPages); list.DataBind(); } else { // Retrieve list of products on catalog promotion list.DataSource = CatalogAccess.GetProductsOnCatalogPromotion(page, out howManyPages); list.DataBind(); } // display paging controls if (howManyPages > 1) { // have the current page as integer int currentPage = Int32.Parse(page); // make controls visible pagingLabel.Visible = true; previousLink.Visible = true; 18 Tr n Phư ng Hoàng – PTN BMCNPM – Khoa CNTT – DHKHTN
  19. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 nextLink.Visible = true; // set the paging text pagingLabel.Text = "Page " + page + " of " + howManyPages.ToString(); // create the Previous link if (currentPage == 1) previousLink.Enabled = false; else { NameValueCollection query = Request.QueryString; string paramName, newQueryString = "?"; for (int i = 0; i < query.Count; i++) if (query.AllKeys[i] != null) if ((paramName = query.AllKeys[i].ToString()).ToUpper() != "PAGE") newQueryString += paramName + "=" + query[i] + "&"; previousLink.NavigateUrl = Request.Url.AbsolutePath + newQueryString + "Page=" + (currentPage - 1).ToString(); } // create the Next link if (currentPage == howManyPages) nextLink.Enabled = false; else { NameValueCollection query = Request.QueryString; string paramName, newQueryString = "?"; for (int i = 0; i < query.Count; i++) if (query.AllKeys[i] != null) if ((paramName = query.AllKeys[i].ToString()).ToUpper() != "PAGE") newQueryString += paramName + "=" + query[i] + "&"; nextLink.NavigateUrl = Request.Url.AbsolutePath + newQueryString + "Page=" + (currentPage + 1).ToString(); } } } } T o thư m c ProductImage và copy hình nh vào - 3.3 Catalog.aspx - Thành ph n GUI
  20. Phát triển ứng dụng Web ASP.NET – 08CDITEC 2010 Runat="server" /> Kéo th ProductList.ascx vào thành ph n Catalog.aspx (theo hư ng d n) - - Thành ph n code using System; using System.Collections; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; public partial class Catalog : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { PopulateControls(); } // Fill the page with data private void PopulateControls() { // Retrieve DepartmentID from the query string string departmentId = Request.QueryString["DepartmentID"]; // Retrieve CategoryID from the query string string categoryId = Request.QueryString["CategoryID"]; // If browsing a category... if (categoryId != null) { // Retrieve category details and display them CategoryDetails cd = CatalogAccess.GetCategoryDetails(categoryId); catalogTitleLabel.Text = cd.Name; catalogDescriptionLabel.Text = cd.Description; // Set the title of the page this.Title = BalloonShopConfiguration.SiteName + " : Category : " + cd.Name; } // If browsing a department... else if (departmentId != null) 20 Tr n Phư ng Hoàng – PTN BMCNPM – Khoa CNTT – DHKHTN
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2