Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Professional ASP.NET 3.5 in C# and Visual Basic Part 16. Building on the revolutionary ASP.NET 2.0 release, ASP.NET 3.5 adds several key new developer features including AJAX, LINQ, and a new CSS designer in Visual Web Developer 2008. The dramatic reduction in code that developers realized from the more than 50 new server controls in ASP.NET 2.0 now allows developers the time to make their applications more interactive with AJAX, to work with data in their preferred language with LINQ, and to build visually attractive and consistent standards-based sites with CSS. . | Chapter 2 ASP.NET Server Controls and Client-Side Scripts using System.Web.UI.WebControls.WebParts using System.Web.UI.HtmlControls using System.Data.SqlClient public partial class Default2 System.Web.UI.Page System.Web.UI.ICallbackEventHandler private string _callbackResult null protected void Page_Load object sender EventArgs e string cbReference Page.ClientScript.GetCallbackEventReference this arg GetCustDetailsFromServer context string cbScript function UseCallback arg context cbReference Page.ClientScript.RegisterClientScriptBlock this.GetType UseCallback cbScript true region ICallbackEventHandler Members public string GetCallbackResult return _callbackResult public void RaiseCallbackEvent string eventArgument SqlConnection conn new SqlConnection Data Source . Initial Catalog Northwind User ID sa SqlCommand cmd new SqlCommand Select From Customers Where CustomerlD eventArgument conn conn.Open SqlDataReader MyReader MyReader cmd.ExecuteReader CommandBehavior.CloseConnection string MyValues new string 11 while MyReader.Read MyValues 0 MyReader CustomerID .ToString MyValues 1 MyReader CompanyName .ToString MyValues 2 MyReader ContactName .ToString MyValues 3 MyReader ContactTitle .ToString MyValues 4 MyReader Address .ToString MyValues 5 MyReader City .ToString MyValues 6 MyReader Region .ToString MyValues 7 MyReader PostalCode .ToString MyValues 8 MyReader Country .ToString MyValues 9 MyReader Phone .ToString 103 Chapter 2 ASP.NET Server Controls and Client-Side Scripts MyValues 10 MyReader Fax .ToString _callbackResult String.Join MyValues endregion Much of this document is quite similar to the document in the previous example using the callback feature. The big difference comes in the RaiseCallbackEvent method. This method first performs a select statement on the Customers database based upon the CustomeriD passed in via the eventArgument variable. The result retrieved from this select statement is then made part of a string array which is finally concatenated