Professional ASP.NET 3.5 in C# and Visual Basic Part 110

Professional in C# and Visual Basic Part 110. Building on the revolutionary release, 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 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 22 State Management Figure 22-4 Listing 22-5 A serializable object that can be used in the out-of-process Session VB Serializable _ Public Class Person Public firstName As String Public lastName As String Public Overrides Function ToString As String Return Person Object 0 1 firstName lastName End Function End Class 1048 Chapter 22 State Management C Serializable public class Person public string firstName public string lastName public override string ToString return Person Object 0 1 firstName lastName Because you put an instance of the Person class from Listing 22-5 into the Session object that is currently configured as Stateserver you should add a strongly typed property to the base Page class from Listing 22-3. In Listing 22-6 you see the strongly typed property added. Note the cast on the property Get and the strongly typed return value indicating that this property deals only with objects of type Person. Listing 22-6 Adding a strongly typed property to SmartSessionPage VB Public Class SmartSessionPage Inherits Private Const MYSESSIONPERSONKEY As String myperson Public Property MyPerson As Person Get Return CType Session MYSESSIONPERSONKEY Person End Get Set ByVal value As Person Session MYSESSIONPERSONKEY value End Set End Property End Class C public class SmartSessionPage private const string MYPERSON myperson public Person MyPerson get return Person Session MYPERSON set Session MYPERSON value 1049 Chapter 22 State Management Now add code to create a new Person populate its fields from the text box and put the instance into the now-out-of-process Session State Service. Then retrieve the Person and write its values out to the browser using the overloaded ToString method from Listing 22-5. Certain classes in the Framework Class Library are not marked as serializable. If you use objects of this type within your own objects these objects are not serializable at all. For example if you .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.