TAILIEUCHUNG - Displaying an Image from a Database in a Web Forms Control

[ Team LiB ] Recipe Displaying an Image from a Database in a Web Forms Control Problem You need to display an image from a database column in an control. Solution Fill an Image control from a database field by pointing the ImageUrl property | Team LiB Recipe Displaying an Image from a Database in a Web Forms Control Problem You need to display an image from a database column in an control. Solution Fill an Image control from a database field by pointing the ImageUrl property of an Image control to a web page that retrieves the image from the database. The solution contains three files the Web Forms page to display the image its code-behind file and the code-behind page that serves the image. The Web Forms page sample code displays the employee image in the Image control employeelmage. The code for the Web Forms page is shown in Example 7-13. Example 7-13. File asp Image id employeeImage style Z-INDEX 102 LEFT 16px POSITION absolute TOP 56px runat server asp Image The code-behind used with the Web Forms page contains one event handler Sets the ImageUrl property of the employeeImage Image control to the web page that serves the employee image then a parameter passed in the URL indicates the employee ID to retrieve. The C code for the code-behind is shown in Example 7-14. Example 7-14. File using System . . . private void Page_Load object sender e Set the image URL to the page containing just the image. EmployeeId The code-behind that serves the image contains one event handler Retrieves the image from the database for the specified employee ID. The image is served by setting the HTTP MIME type of the output stream to image bmp and writing the image to the stream. The C code for the code-behind is shown in Example 7-15. Example 7-15. File Namespaces variables and constants using System using using using . . . private void Page_Load object sender e Create the command to retrieve employee image specified. SqlConnection conn new .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.