Asp.net uploads images for preview

Source: Internet
Author: User

1. Put an upload control and an image control on the page.

 

<Asp: fileupload id = "fileupload1" runat = "server" onpropertychange = "show (this. Value)"/>
<Asp: Image id = "image1" runat = "server"/>

2. Write the onpropertychange = "show (this. Value)" event in the upload control, call the show function in JS, and pass its parameters to Js.

 

<SCRIPT type = "text/JavaScript">
Function show (ID)
...{
Document. getelementbyid ("image1"). src = ID;
}
</SCRIPT>

IE6, IE7 passed the test (Note: implement through filter)

 

<Div id = "divview" style = "filter: progid: DXImageTransform. Microsoft. alphaimageloader (sizingmethod = image); width: 166px; Height: pixel PX">
<! -- Used to display images -->


</Div>

<Asp: fileupload id = "fileupload3" runat = "server" onpropertychange = "show1 (this. Value)"/>

 

 

<SCRIPT type = "text/JavaScript">

Function show1 (upimg)
...{
VaR dd = Document. getelementbyid ("divview ");
Dd. Filters. Item ("DXImageTransform. Microsoft. alphaimageloader"). src = upimg;
Dd. style. width = 166;
Dd. style. Height = 190;
Dd. Filters. Item ("DXImageTransform. Microsoft. alphaimageloader"). sizingmethod = 'Scale ';
}

</SCRIPT>

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.