ASP. NET implements a pop-up window for adaptive image size (the window can be edited at Will)

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 = .. \ computer \ downloadfiles \ article \ 26 \ <% # 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.



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.