I am working on a video upload module, which ultimately stores all the user uploaded video's on the youtube (using youtube api's).
I want to display a progress bar as soon as user click's on upload button and continue showing until the video is uploaded.
I know generally this is achieved using ajax toolkit in .net but since I am using File Upload control, its not compatible with the ajax toolkit.
Kindly suggest me how I achieve this.
You can not show the actual progress of the file upload. But you can show a hidden animated "loading" image with javascript. It will show while the form is submitted (with the file) to the server.
Html:
<img id="loading_img" style="Display: None" src="loading.gif" />
Javascript:
$('#Form1').submit(function() {
$('#loading_img').show(); // Show image
return true; // Proceed with postback
});
A while ago I needed exaclty that, I first did search for a javascript solution but ended up with a Flash uploader. Some browsers (Chrome, Firefox) report uploading status if you're uploading through the XMLHttpRequest API in Javascript, so it definitely can be done, but this method is (or was at the time I checked it out) not cross-browser.
You can check this example and also this Q & A.
If that doesn't work cross-browser, you can use an existing Flash file uploader or create one your own using Flash or Silverlight. This, of course, makes your site Flash or Silverlight dependent.
This, for example, is a project that uses Flash.
Fastest way to do that is to buy 3rd party control, for example Telerik Upload control can do that (no flash)
http://demos.telerik.com/aspnet-ajax/upload/examples/customizingraduploadui/defaultcs.aspx
Related
I have a functionality where I need to upload a multi-page document. For display purposes, I have to give the user ability to view it page-vise. I have to show no. of pages and then user can navigate back and forth between the pages to view each page.
Any pointers on how this can be accomplished? I am using ASP.Net MVC3 and C# as the language.
Much Thanks!
If by "multi-page document" you mean like a PDF or word doc, then you'll need to embed a 3rd party viewer in your page and have it display. Generally they have the functionality you've mentioned built-in.
I want to show javascript code in my webbrowsers in C#. Normally, When I navigated, browser wants to save it.. But I want browser shows it on browser's screen.. I think that I must do a javascript viewer with webbrowser..
I used like that code but it doesnt work (still asking to save..)
webBrowser1.Navigate("http://xxxx.com/aaa.js", "_mainframe");
Don't use a WebBrowser control for this but simply download it using a HttpClient and display it e.g. in a TextBox.
The WebBrowser control is basically an embedded IE which will download files if it thinks a file with that MIME type should be downloaded or if there are headers like Content-disposition: attachment (which force a download prompt in the browser).
I have a FileUpload control in my aspx page and I want to display the image selected before postback so that user confirms the image to upload.
You can use this AJAX Control Toolkit Control for Image Confirmation.
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AsyncFileUpload/AsyncFileUpload.aspx
What you're looking for would require a pure client-side solution, which I do not think is possible since they do not have access to the file system(under normal circumstances).
Note that using AJAX requires actually sending the file to the server first.
This Can be done VIA HTML5 now,
http://www.html5rocks.com/en/tutorials/file/dndfiles/
When the upload is selected you want to read the file with
readAsBinaryString
Then you would need to turn that binary to Base64 so you could display it on the page,
http://www.webtoolkit.info/javascript-base64.html
Then you will need to put it into an img tag on the in the src E.G
<img src="data:{image/mime_type};base64,{base64_binary_data}" width="100" height="100" />
Where {image/mime_type} is the mime type of the image they have uploaded E.G image/png, image/jpg
And {base64_binary_data} is the readAsBinaryString after it's gone though the base64 conversion
It's not possible through HTML. But it may be possible using flash/silverlight.
I say this because I remember coming across an issue when I wanted to know up front how big a file was before the user uploaded it. Html doesn't give you the ability to know this, the user must upload the whole file before you can say how big it is.
However, the workaround was to use flash because flash seems to have permissions to grab data about a file from the local disk before sending it to the server (after the user selects the file of course). Since it can grab the filename, size, etc then I imagine you'll be able to grab the image data too and then display it.
You're going to need to use flash or silverlight to do that.
Here's an article where it's explained how to do that with flash:
http://blog.flexexamples.com/2008/08/25/previewing-an-image-before-uploading-it-using-the-filereference-class-in-flash-player-10/
I have a web app that displays the profile of over 600 people, and each profile displays a word cloud. the word cloud is rendered using html.
The client has requested that the same word cloud to appear in an excel macro that pretty much does the same thing as the web app.
I have seen a few solutions that saves image from rendered page but is there a way to create images from the html programatically, without selecting each of the 600 profiles manually.
Since rendering html is a browser's job, you could take a look at doing it by javascript.
Write a nice little program in jQuery (or your favorite js framework) that renders the word cloud of every profile on a canvas, and then use this:
http://www.nihilogic.dk/labs/canvas2image/
to take an image of the rendered html.
I know it has been a while since I asked this question but I'll answer it for the benefit of others. I ended up using something called IECapt to capture rendering of a web page into a BMP, JPEG or PNG image file;
http://iecapt.sourceforge.net/
I then wrote a unit test to iterate over the various urls, passing it as an argument to the IECapt utility. Was able to render over 600 images in a few seconds.
On the server that my application is being run on, a virtual PDF printer is being installed (don't know much about this yet, except it's from Adobe), and my application needs to use this 'printer' to create PDF's from HTML pages (a GridView mostly), and then redirect the user to the URL of the where the PDF is stored.
I've been looking at the PrintDocument object in System.Drawing.Printing, however I've read that you can't simply feed this a HTML page. What are my choices? The easiest option would be to be able to 'print' a given HTML page (choosing what and what not to print using CSS), but from what I've read this is fairly difficult, so I'm thinking about somehow constructing whatever object PrintDocument needs programatically, if that makes sense.
Any ideas on how I should do this?
there are some free/cheap libs for creating pdfs on the fly. I've used itextsharp before and it worked pretty well. Takes a bit of time to get up to speed in how it works but I'd suggest checking it out.
There are also printing services like Neevia DocConverter that will monitor a folder and auto convert whatever you put in the folder to a pdf, jpg, etc. you can set it up so that if you drop a url shortcut in the folder it will render the webpage at that url to pdf. it's a bit more of a pain if you want to do realtime rendering but works excellent for generating mass reports in batches that you want to post up to a website or email later.