What would be the best way to create a C# Web Application that allows the user to browse for an image and then display it?
An equivalent of Picturebox in windows applications, sort of
Ideally the user should be able to click on Browse, choose the picture and see it in the browser itself
Thanks
There are all ready some image-browser for asp.net including source code.
Some of them
http://www.codeproject.com/Articles/17605/Thumbnail-Image-Viewer-Control-for-ASP-NET-2-0
http://www.codeproject.com/Articles/29846/A-simple-ASP-NET-AJAX-image-browser
For this, the user needs to choose an image which will be uploaded to the server, and then rendered in the HTML or recovered using AJAX. The problem is that you can't get rid of the send/receive, and it can get slow.
You can use a FileUpload or any other component that allows to upload files directly or via AJAX (look at AjaxFileUpload AjaxControlToolkit for this).
Then you need to add an <img> to your page, through a full postback or using any other means (like jQuery.Ajax).
Related
I have a Web Browser Control in windows application. I want to save page at specific folder with CSS files and JS files. I have used webBrowser1.ShowSaveAsDialog() method but by this user can save page at any location instead of my application folder.
So, how can I save pages with folder structure to my location without showing pop up menu?
Good question!! all the browsers do it, iMacros ($495-$990) does it
Selenium, phantomjs, slimer, watir, etc CAN'T do it,
the closest i have seen to that sort of functionality is...
http://www.codeproject.com/Articles/2847/Automated-IE-SaveAs-MHTML
which uses c++ to hack the save as dialog.
You'd think that SaveAs webpage complete would be just another
method on the browser control. But it doesn't seem so. I want
this functionality as well -- sorry this question remains unanswered.
I am trying to create a wizard using jquery (fill in a dialog of info, press next, dialog changes but page does not refresh). During this process I would like to upload a file to a document library. I do not wish to reload the page. Is this possible? How would you go about doing this?
You can use uploadify plugin here, which uses a flash component to upload files and it provides events for almost every state of uploading, so you can fire your functions whenever you want for changing content showing alerts etc...
As redsquare says there are also other plugins, but i used this one in a project and it works pretty well.
Hope it helps,
Sinan.
I'm creating a website that is able to do multiple file uploads. However, is it possible such that when I click on the browse button and select the file to upload, it automatically adds it to a list of files to be uploaded, instead of selecting the file, and having another button to add that selected file to the list? It is something like uploadify.
Thanks.
I use Ajax Uploader for this
Latest build of Ajax Control Toolkit allows you to upload files without refreshing a page and without using addition button (not sure for multiuploading).
Also you may be interested in "[How Do I:] Multiple File Uploads in ASP.NET 2".
Without using a third-party control, is it possible to automatically begin uploading a file as soon as the user selects a file and the file browser window closes? I have the data struture in place as well as all the information needed to capture the data, but I need a way of knowing if the file upload has changed? Is there an event that fires, or something I can capture to achieve this?
Thanks,
George
No. Not without using a third-party control.
It looks like it is possible using a hidden <IFRAME>. Check out the AJAX File Uploader.
There are simple Silverlight and Flash solutions available as well, however.
I have a web page which displays some report. When I click on the link for excel, it puts all the data that is displayed on the screen into a CSV file and opens a File Download window which lets me either Open, Save or Cancel.
I want to download this file to a specified location programatically without the user seeing the File Download window. I am using a Windows Application. I dont have the code for the website displaying this report hence dont have the dataset. Also, I looked into the HTML that gets generated by doing a view source on the page but I can't really scrape through it to get the data.
Hence I need to know how to download an excel file from a given website to a location on my computer.
Thanks in advance
Rita
Well you'll need to find the appropriate link or post action. You can then use something like:
string url = "http://whatever/.../foo.xsl";
string target = #"c:/excel documents/foo.xsl";
WebClient client = new WebClient();
client.DownloadFile(url, target);
It gets a bit more complicated if you need to authenticate etc though.
I assume that you're showing the web page within a WebBrowser control. You can handle the WebBrowser.Navigating Event and inspect the value of the WebBrowserNavigatingEventArgs URL property to see if string.EndsWith(".csv", CurrentCultureIgnorecase) (or perhaps a more specific test).
If you detect that the link that has been clicked is for a file you wish to download then you can call e.Cancel() = True on the WebBrowserEventArgs instance to stop the browser from proceeding with its normal behavior of opening the File Download dialog. Then you can use .NET's HttpWebRequest and HttpWebResponse classes to manually download the file.
Here's a sample of downloading using these classes
Actually I am doing a screen scraping, so I am not displaying the web page.
What I have done is gone to the URL where the report is displayed on the screen. There is a hyperlink for 'Excel'. I make this hyperlink click from my program itself. On clicking this link, it opens the File Download dialog box.
I have written, the WebBrowser.Navigating and Navigated events, but the control does not come here. Any ideas
1 more thing, the site that I am accessing is java website.