asp.net display picture to the specified image control specific implementation _ practical tips

Source: Internet
Author: User

Because the image control in asp.net is in the System.Web.UI.WebControls namespace, you cannot display the picture directly, as in WinForm, through byte[.

In this way, we can only curve the nation. The example here is the idea that teacherdetial.aspx is the final page to display text and pictures, but since our pictures need to be curved to save the nation, here's another pic.aspx. In the Pic.aspx page we display the picture and set the URL of the image control in teacherdetial.aspx to Pic.aspx. Finally we finished the request.

Teacherdetial.aspx's code is as follows

Copy Code code as follows:

<TD height= "align=" "right" > Photo: </td>
<td>
<asp:image id= "Image1" runat= "Server" width= "" "height=" "/>"
</td>

Teacherdetial.aspx.cs's code is as follows

Copy Code code as follows:

private string tid = null;
protected void Page_Load (object sender, EventArgs e)
{
tid = request.params["Tid"];
This. Image1.imageurl = "~/teacher/pic.aspx?tid=" + tid;
}

So we move the display of the picture to another page, and our image control just displays another page.

Pic.aspx's code is simple, just a new page can be.

The code for Pic.aspx.cs is as follows:

Copy Code code as follows:

protected void Page_Load (object sender, EventArgs e)
{
String tid = request.params["Tid"]. ToString ();
Teacherdao td = New Teacherdao ();
Response.BinaryWrite (Td.getpic (TID));
}

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.