I get data from the database in which is images and some other fields, now I want that when I click on the Image they open in the new window my code is
<a target="_blank" href="#">
<img alt="" src="<%#"data:Image/png;base64,"+Convert.ToBase64String((byte[])Eval("ImageData")) %>"" width="200" height="200" />
</a>
what should I do this img pass to next window and display large or actual size
You need to add some javascript to your code.
// HTML
<a target="_blank" href="#" onClick='test(this)'>
<img alt="" src="<%#"data:Image/png;base64,"+ Convert.ToBase64String((byte[])Eval("ImageData")) %>"" />
</a>
// Javascript Code
function test(element) {
var newTab = window.open();
setTimeout(function() {
newTab.document.body.innerHTML = element.innerHTML;
}, 500);
return false;
}
Demo Fiddle
The href
attribute of the a
tag has to contain the same filepath as the src
attribute inside the img
tag. You already added target="_blank"
, so the image will open in a new window, in original size, showing nothing else than the image.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With