Problem of garbled address of image in image control during ASP.

Source: Internet
Author: User

The front page is like this:

<%--Photo Gallery 20140705add--%>
<div id= "Imgshowdiv" style= "left:550px; top:90px; height:430px; Display:none; "class=" MsgBoxStyle ">

<a id= "A1" onclick= "Closedlg (This)" href= "#" class= "Iclose" title= "Close or hide" ></a>
<div style= "top:30px; Position:absolute; " >
<a href= "" target= "_blank" id= "Atp_yyzz" >

</a>
</div>
</div>

The associated JS is: Drag_layer.js and imgshowfuncs.js, in addition to referencing a imagezoom.css style file

Click on the picture when the new page opens the original image but the path will be error, so I added the first sentence in the Pageload solution:

request.contentencoding = System.Text.Encoding.GetEncoding ("GB2312");
string args = request.params["args"]. ToString ();
string imgpath = args;
System.IO.FileStream afile = new System.IO.FileStream (Imgpath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
Create a binary data stream reader, and open file associations
System.IO.BinaryReader brmyfile = new System.IO.BinaryReader (afile);
Reposition the file pointer to the beginning of the file
BrMyfile.BaseStream.Seek (0, System.IO.SeekOrigin.Begin);
Get a byte array of photos
byte[] photo = Brmyfile.readbytes (Convert.ToInt32 (aFile.Length.ToString ()));
Close each of these new objects
Brmyfile.close ();
Response.BinaryWrite (photo);

The problem is to request or return when the encoding method is not correct, write code when more attention, problems more analysis can be.

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.