ASP. NET implemented adaptive image size pop-up window

Source: Internet
Author: User
In a recent project, we encountered a problem to achieve this effect:
Click the thumbnail on the pic_small.aspx page and the pic_all.aspx page is displayed. The size of the pic_all.aspx page must be adjusted automatically based on the image size and the image description must be provided, you can also click the previous image or the next image to flip the page.
The implementation process is as follows:
Pic_small.aspx Code Is:
) "src = '<% #" images/product/"+ databinder. eval (container. dataitem, "picurl") %> 'width = "118" runat = "server">

Showwindow is saved in the openwindows. js file with the following content:

Function showwindow (ID)
{
Window. Open ('pic _ all. aspx? Id = '+ id,' _ blank ', 'rollbars = no ');
}
 
The following code displays the image information on the pic_all.aspx page after a thumbnail is clicked. The pic_all.aspx page is automatically adjusted based on the image size.
Place the following code between

<SCRIPT>
Function window. onload ()
{
VaR OBJ = Document. getelementbyid ("picurl ");
Window. resizeTo (obj. offsetwidth + 127, obj. offsetheight + 75 );
}
</SCRIPT>

Here, picurl is used to display the source image size in pic_all.aspx. I use the HTML control. No matter what method you use, you need to read the image name or path from the database.
OBJ. offsetwidth returns the width of the displayed source image, obj. offsetwidth + 127 indicates that the window is 127 pixels larger than the image width, because you need to leave some space for the image description.
In this way, the pop-up window can be automatically adjusted according to the image size, and the pop-up page can be edited at will, because the pop-up page is a specified page, no matter what you want to edit, You can process the page as usual.

thanks to bohu for providing the key code for the entire implementation process. If it weren't for his help, I couldn't complete the project today, so I couldn't leave the company with peace of mind, I would like to express my heartfelt thanks to everyone who is enthusiastic about helping others. This is why I have written all the problems encountered in the project and hope to help more people.

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.