Geeks With Blogs

News

Microsoft MVP


Moderator at CodeASP.NET


Quiz Master




free counters
Free counters
Added on January 19,2012


Follow Me @vmsdurano

A bit About Me



Disclaimer
The opinions expressed herein are my own personal opinions and does not represent the opinions of my employers. Nor does it represent the opinion of my dog, because I don’t have one.


Vinz' Blog (ProudMonkey) "Code, Beer and Music ~ my way of being a programmer"

The following snippet below will display the original Image size in new window when clicking on the image thumbnail using JavaScript..

JAVASCRIPT FUNCTION

<script type="text/javascript" language="javascript">
    function DisplayNewImageInWidnow()
    {
       var img = document.getElementById('<%= Image1.ClientID %>').src;

        html = "<HTML><HEAD><TITLE>Photo</TITLE>"
        +  "</HEAD><BODY LEFTMARGIN=0 "  
        + "MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0><CENTER>"  
        + "<IMG src='"
        + img
        + "' BORDER=0 NAME=image "  
        + "onload='window.resizeTo(document.image.width,document.image.height)'>" 
        + "</CENTER>"  
        + "</BODY></HTML>";
        popup= window.open  ('','image',  'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1');
        popup.document.open();
        popup.document.write(html);
        popup.document.focus();
        popup.document.close();
}

</script>

ASPX Image Control MARKUP

<asp:Image ID="Image1" width="100px" height ="100px"  runat="server" ImageUrl = "Images/PublicPrivateChart.gif" onclick="DisplayNewImageInWidnow();"/>

Happy Coding!

Technorati Tags: ,,
Posted on Thursday, September 11, 2008 10:38 AM ASP.NET , JavaScript , Tips&Tricks | Back to top


Comments on this post: Display Original Image Size in new window when clicking on the Image

# re: Display Original Image Size in new window when clicking on the Image
Requesting Gravatar...
Hello! i have a problem using this script that is this script is only to enlarge one image, if we have multiple images on asp.net page with surely different ID's then what can we do to enlarge each after mouse click. Please Help!

Thanks in advance!
Left by Zeeshan Hassan on Jul 19, 2009 2:48 AM

# re: Display Original Image Size in new window when clicking on the Image page with surely different ID's
Requesting Gravatar...
function DisplayNewImageInWidnow(imagectl)
{
Field = imagectl;
html = "<HTML><HEAD>"
+ "</HEAD><BODY LEFTMARGIN=0 "
+ "MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0><CENTER>"
+ "<IMG src='"
+ Field.src
+ "' BORDER=0 NAME=image "
+ "onload='window.resizeTo(document.image.width,document.image.height)'>"
+ "</CENTER>"
+ "</BODY></HTML>";
popup= window.open ('','image', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=2,resizable=1');
popup.document.open();
popup.document.write(html);
popup.document.focus();
popup.document.close();
}

ASPX Image Control MARKUP

<asp:Image ID="Image1" width="100px" height ="100px" runat="server" ImageUrl = "Images/PublicPrivateChart.gif" onclick="DisplayNewImageInWidnow(this);"/>
Left by bhavna patel on Sep 03, 2009 7:38 PM

# re: Display Original Image Size in new window when clicking on the Image
Requesting Gravatar...
It is a nice article but i am facing diffarant problem.I am using GeneratedImage control to display the image so its not having any source URL property.Images are displaying dynamically.So can you please tell me using GeneratedImageControl of ASP.net how i can show full size image.
Left by Priyanka on Sep 09, 2009 9:13 PM

comments powered by Disqus

Copyright © Vincent Maverick Durano | Powered by: GeeksWithBlogs.net | Join free