ASP. NET uses controls to display local pictures

Source: Internet
Author: User
Image/imagebutton server control Displays the local picture, realizes the idea is the database holds the picture the relative address, reads the address in the database, uses the control to load the display picture. The concrete implementation of the steps are referred to this article

The Image/imagebutton server control displays a local picture. Here, I do is: The database contains the relative address of the picture, read the address in the database, with the control to load the display picture.

Steps:

A, add a server control, where the image control is an example.

B, the path in the database, this is very important. The format I wrote was this: ~/image/1.jpg. I wrote before: ~\image\1.jpg, the picture shows that the load failed, changed the ' \ ' after, you can. Image is a folder that I've created in my project's home directory to specifically store pictures.


C, add code. To add a picture path using the ImageUrl property of Image:


Avatar    image_portrait. ImageUrl  = ds. Tables[zer]. Rows[zer][six]. ToString ();



D. Results

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.