Đang chuẩn bị liên kết để tải về tài liệu:
ASP.NET 4 Unleased - p 25

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

CẢNH BÁO Nếu bạn tạo ra một xử lý sự kiện cho sự kiện AdCreated và bạn có bộ nhớ cache của trang, nội dung do người điều khiển AdRotator cũng lưu trữ. Khi xử lý các sự kiện AdCreated, sử dụng một phần bộ nhớ đệm cache trang để chỉ một phần của một trang và không kiểm soát AdRotator chính nó. | 214 CHAPTER 4 Using the Rich Controls WARNING If you create an event handler for the AdCreated event and you cache the page the content rendered by the AdRotator control is also cached. When handling the AdCreated event use partial page caching to cache only part of a page and not the AdRotator control itself. The page in Listing 4.14 displays a banner advertisement with the AdRotator control. The page includes an event handler for the AdRotator control s AdCreated event. LISTING 4.14 AdRotatorTrack.aspx @ Page Language C DOCTYPE html PUBLIC - W3C DTD XHTML 1.0 Transitional EN http www.w3.org TR xhtml1 DTD xhtml1-transitional.dtd script runat server protected void AdRotator1_AdCreated object sender AdCreatedEventArgs e Update Impressions srcAds.InsertParameters AdId .DefaultValue e.AdProperties Id .ToString srcAds.Insert Change NavigateUrl to redirect page e.NavigateUrl AdHandler.ashx id e.AdProperties Id .ToString script html xmlns http www.w3.org 1999 xhtml head id Head1 runat server title AdRotator Track title head body form id form1 runat server div asp AdRotator id AdRotator1 DataSourceID srcAds OnAdCreated AdRotator1_AdCreated Runat server asp SqlDataSource id srcAds ConnectionString Server . SQLExpress Integrated Security True From the Library of Wow eBook Displaying Advertisements 215 AttachDbFileName DataDirectory AdListDB.mdf User Instance True SelectCommand SELECT Id ImageUrl Width Height NavigateUrl AlternateText Keyword Impressions FROM AdList InsertCommand INSERT AdStats AdId EntryDate Type VALUES @AdId GetDate 0 Runat server InsertParameters asp Parameter Name AdId Type int32 InsertParameters asp SqlDataSource div form body html 4 The AdCreated event handler does two things. First it inserts a new record into a database table named AdStats which records an advertisement impression. Second the handler modifies the NavigateUrl so that the user is redirected to a handler named AdHandler.ashx. The AdStats database table looks like this Column Name Data .

TÀI LIỆU LIÊN QUAN
crossorigin="anonymous">
Đã 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.