Image Preview using in Dynamic image Controls without uploading image in Folder or database.

Posted by Skkanagaraj under ASP.NET AJAX on 12/26/2013 | Points: 10 | Views : 949 | Status : [Member] | Replies : 2
Image preview from AsyncFileUpload in Image control using Dynamic Controls, Asp.net without uploading image in Folder or database. (or)
How we can preview LocalImage in asp.net image Dynamic Control.

Then i directly Assign file path to image1.Imageurl, image is not previewing the image control

Sir i tried this, using javascript. It is working in IE only. But it is not supported for all browsers




Responses

Posted by: Prabhukiran345 on: 12/27/2013 [Member] Starter | Points: 25

Up
0
Down
Hi raj,

Once check this code.. This may helpful for you
$(document).ready(function ()
{
//Photo Preview
$("#uploadImg").change(function ()
{
readURL(this);
});
});
function readURL(input)
{
if (window.navigator.appName == 'Microsoft Internet Explorer')
{
//if (parseInt(jQuery.browser.version, 10) < 10)
{
$.ajax({
url: '@Url.Action("GetImage", "Home")',
type: "GET",
data: { 'sourcePath': input.value },
success: function (result)
{
$("#employeeImg").removeAttr('src');
$("#employeeImg").attr('src', result);
},
error: function (msg)
{
//alert('To get Image Preview, Please Enable => Tools -> internetOptions->Security -> Custolevel -> Include Local Directory path...');
}
});

}
// else
// {
// var reader = new FileReader();
// reader.onload = function (e)
// {
// $('#employeeImg').attr('src', e.target.result);
// }
// reader.readAsDataURL(input.value);
// }
}
else
{
if (input.files && input.files[0])
{
var reader = new FileReader();
reader.onload = function (e)
{
$('#employeeImg').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}

}


Thanks,
Prabhu Kiran B

(Please Mark as answer if this post is helpful)


Thanks,
Prabhu Kiran Bommareddy

Skkanagaraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Skkanagaraj on: 1/3/2014 [Member] Starter | Points: 25

Up
0
Down
Thank you

Skkanagaraj, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response