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

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

Các công thức thống kê và tài chính được xây dựng trong kiểm soát đồ làm cho nó dễ dàng để thêm các phân tích mạnh mẽ để ứng dụng web của bạn với các mã tùy chỉnh nhỏ. Trong quá khứ, thêm vào những thứ như striplines và thực hiện tính toán bổ sung vào một loạt dữ liệu đã được hoặc là một cái gì đó bạn phải mã chính mình hoặc cái gì đó mà chi phí rất nhiều thêm tiền khi mua điều khiển biểu đồ từ nhà cung cấp. Với ASP.NET 4, tất cả các. | 304 CHAPTER 7 Creating Custom Controls with User Controls div form body html You need to be aware of one important limitation when registering a User control in the web configuration file. A User control cannot be located in the same folder as a page that uses it. For that reason you should create all your User controls in a subfolder. Exposing Properties from a User Control The Randomimage User control always displays an image from the Images folder. It would be nice if you could specify the name of the folder that contains the images so that you could use different folder paths in different applications. You can do this by exposing a property from the Randomimage User control. The modified Randomimage control in Listing 7.5 named PropertyRandomimage exposes a property named ImageFolderPath. LISTING 7.5 PropertyRandomimage.ascx @ Control Language C ClassName PropertyRandomimage @ import Namespace System.iO script runat server private string _imageFolderPath - images public string imageFolderPath get return _imageFolderPath set _imageFolderPath value void Page_Load string imageToDisplay GetRandomimage imgRandom.imageUrl Path.Combine _imageFolderPath imageToDisplay lblRandom.Text imageToDisplay private string GetRandomimage Random rnd new Random string images Directory.GetFiles MapPath imageFolderPath .jpg string imageToDisplay images rnd.Next images.Length return Path.GetFileName imageToDisplay From the Library of Wow eBook Creating User Controls 305 script asp Image id imgRandom Width 300px Runat server br asp Label id lblRandom Runat server After you expose a property in a User control you can set the property either declaratively or programmatically. The page in Listing 7.6 sets the ImageFolderPath property declaratively. LISTING 7.6 ShowDeclarative.aspx @ Page Language C @ Register TagPrefix user TagName PropertyRandomImage Src PropertyRandomImage.ascx DOCTYPE html PUBLIC - W3C DTD XHTML 1.1 EN http www.w3.org TR xhtml11 DTD xhtml11.dtd html xmlns http .

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.