Reputation: 13248
I would like to know that On Page refresh
I would like to display
more than 40+ images
which are already existed
in my server folder
to be displayed in a div control which already exists and add those images to that div
As of now I can display one image using as shown below:
Preview.ImageUrl = "~/DownloadImages/" & Session("tempDir").ToString & "/" & filename
I would like to know the better solutions!
Here is how the images are generated:
<script type="text/javascript">
$(function () {
$("#<%=uploader.ClientId%>").plupload({
runtimes: 'gears,flash,silverlight,browserplus,html5',
url: 'Default.aspx',
max_file_size: '10mb',
max_file_count: 21,
chunk_size: '1mb',
unique_names: true,
rename: true,
dragdrop: true,
filters: [
{ title: "Image files", extensions: "jpg,gif,png" },
{ title: "Zip files", extensions: "zip" }
],
flash_swf_url: 'js/plupload.flash.swf',
silverlight_xap_url: 'js/plupload.silverlight.xap'
});
$('form').submit(function (e) {
var uploader = $('#<%=uploader.ClientId%>').plupload('getUploader');
if (uploader.files.length > 0) {
uploader.bind('StateChanged', function () {
if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
$('form')[0].submit();
}
});
uploader.start();
}
else
//alert('You must at least upload one file.');
return false;
});
var uploader = $('#<%=uploader.ClientId%>').plupload('getUploader');
uploader.bind('FilesAdded', function (up, files) {
var i = up.files.length,
maxCountError = false;
plupload.each(files, function (file) {
setTimeout(function () {
up.start();
}, 100);
if (uploader.settings.max_file_count && i >= uploader.settings.max_file_count) {
$.msgBox({
title: "Info",
content: "Max Files Reached.",
type: "info",
showButtons: true,
opacity: 0.1,
autoClose: false
});
uploader.removeFile(up.files[i - 1]);
} else {
}
});
});
var uploader = $('#<%=uploader.ClientId%>').plupload('getUploader');
uploader.bind('FileUploaded', function (up, file, res) {
$('#<%=thumbs.ClientId%>').append("<div id=" + file.id + "><a href='Uploads/" + document.getElementById("<%=currentDirectory.ClientId%>").value + "/" + file.name + "' rel='group1'><img class='clickImage' src='Uploads/" + document.getElementById("<%=currentDirectory.ClientId%>").value + "/" + file.name + "' width='75' height='50' data-full='Uploads/" + document.getElementById("<%=currentDirectory.ClientId%>").value + "/" + file.name + "'/></div>");
if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
showStickySuccessToast();
}
});
});
function randomString(length) {
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('');
if (!length) {
length = Math.floor(Math.random() * chars.length);
}
var str = '';
for (var i = 0; i < length; i++) {
str += chars[Math.floor(Math.random() * chars.length)];
}
return str;
}
</script>
If I know how many Images users can add then it's easy but It's hard to say thats the main issue.
Upvotes: 1
Views: 1406
Reputation: 467
You can use Literal or Image Controls and add them on a Panel (or even a div if you add runat="server" to it on the aspx file)
<div id="existingDiv" runat="server"></div>
I prefer Image controls... something like this: (this is a very simple example of course)
foreach(string imageURL in urlsList)
{
var img = new System.Web.UI.WebControls.Image();
img.ImageUrl=imageURL;
img.Width = 200;
img.Height = 100;
this.div1.Controls.Add(img);
}
EDIT: Inside urlsList i load the urls like so: (VB)
Dim urls As New List(Of String) 'I dont know if you need another parenthesis here on VB...
urls.Add("imageurl1")
urls.Add("imageurl2")
Upvotes: 1