I am saving an image file, then using Image namespace to resize the image.
The problem is that from the point of when image is saved to the system, to the point where image resizing is handled, the file handle seem not to get released right away, giving me error "A generic error occurred in GDI+"
Here is my code:
I am using asyncfileupload ajax control, C# in VS 2008
I have a follow-on question to How to display an image based on SelectedValue in a GridView?
What I would really like to do is have a ViewImage button on my GridView control so that when that is clicked, the image is displayed on a new page in a new browser window. How would I do that? I'm thinking perhaps do I need to create a
<asp:ButtonField>
How do I handle the click and how do I get the image to diplay on a new form in a new web browser window?
I have a bit of code in a clickevent handler like this:-
Dim products = From p In db.Products where p.product_name = "Tool" Select New With {p.Product_ID,p.Product_name} Gridview1.Datasource = products GridView1.Databind()
But causes error=SQL Server does not handle comparison of NText, Text, Xml, or Image data types?
I have an ASP.Net web site (ASPX and ASMX pages) with a single web.config file. We have a development version and a production version. Over time, the web.config files for development and production have diverged substantially. What is the best practice for keeping both versions of web.config in source control (we use Tortoise SVN but I don't think that matters)?
It seems like I could add the production web.config file with a name like "web.config.prod", and then when we turnover all the files we would just add the step of deleting the existing web.config and renaming web.config.prod to web.config. This seems hackish, although I'm sure it would work. Is there not some mechanism for dealing with this built in to Visual Studio? It seems like this would be a common issue, but I haven't found any questions (with answers) about this.
In my application the user uploads three files ( Resume, Cover Letter, Selection Creteria).
I want users not to upload more then 4 MB files, so In my web.confing file I have allowed max of 5 MB. <httpRuntime maxRequestLength="5000"/>. I did this so that I can validate the file and give user a message that they are trying to upload more then 4 MB file.
It all works fine if the user is only uploading resume. But if the user uploads all three files of size 4MB then my validation does not work and it goes to connection time out.
How can i handle the validation to check the file size of all 3 files?
i am using selenium for testing website which has functionality for downloading online video.i am using asp.net as language in selenium,each time i press download button save file dialog appears which cant be handle by selenium,how can i handle save file dialog(without using autoIt exe file).is there a way to call autoit script from selenium?or any other method to handle save file dialog???
I'm using a slightly modified version of Valum's upload [github link], I've modified it to upload to a database but haven't modified the javascript that it is using to get the file into the Request as an InputStream. The following line of code is failing in IE 8 but is confirmed to work in Chrome. using (Image imgInput = Image.FromStream(Request.InputStream)) The error received is "Parameter not valid". It appears to be having an issue with the Input Stream being used but it exists/has data (not sure how to validate if the data is good or not).
Page <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Upload-Pictures</h2> <div id="file-uploader"> <noscript> <p>Please enable JavaScript to use file uploader.</p> </noscript> </div> <script src="/Scripts/fileuploader.js" type="text/javascript"></script> <script type="text/javascript"> function createUploader() { var uploader = new qq.FileUploader({ element: document.getElementById('file-uploader'), action: '/Admin/FileUpload/' + <%= Model.PropertyId %>, debug: true }); } window.onload = createUploader; </script> </asp:Content> Controller [AcceptVerbs(HttpVerbs.Post)] public JsonResult FileUpload(int id) { try { byte[] newImageByteArray = GetByteArrayForResizedImage(350, Request.InputStream); byte[] thumbnailByteArray = GetByteArrayForResizedImage(150, Request.InputStream); //Add to DB } catch (Exception ex) { // This is where the exception is caught return Json(new { success = false, message = ex.Message }, "application/json"); } return Json(new { success = true }, "application/json"); } private static byte[] GetByteArrayForResizedImage(int imageSize, Stream inputStream) { byte[] imageByteArray; // For some reason in IE the inputStream here is causing it to crash using (Image imgInput = Image.FromStream(inputStream)) { //Image processing } return imageByteArray; } fileuploader.js - qq.FileUploader /** * Class that creates upload widget with drag-and-drop and file list * @inherits qq.FileUploaderBasic */ qq.FileUploader = function(o){ // call parent constructor qq.FileUploaderBasic.apply(this, arguments); // additional options qq.extend(this._options, { element: null, // if set, will be used instead of qq-upload-list in template listElement: null, template: '<div class="qq-uploader">' + '<div class="qq-upload-drop-area"><span>Drop files here to upload</span></div>' + '<div class="qq-upload-button">Upload a file</div>' + '<ul class="qq-upload-list"></ul>' + '</div>', // template for one item in file list fileTemplate: '<li>' + '<span class="qq-upload-file"></span>' + '<span class="qq-upload-spinner"></span>' + '<span class="qq-upload-size"></span>' + '<a class="qq-upload-cancel" href="#">Cancel</a>' + '<span class="qq-upload-failed-text">Failed</span>' + '</li>', classes: { // used to get elements from templates button: 'qq-upload-button', drop: 'qq-upload-drop-area', dropActive: 'qq-upload-drop-area-active', list: 'qq-upload-list', file: 'qq-upload-file', spinner: 'qq-upload-spinner', size: 'qq-upload-size', cancel: 'qq-upload-cancel', // added to list item when upload completes // used in css to hide progress spinner success: 'qq-upload-success', fail: 'qq-upload-fail' } }); // overwrite options with user supplied qq.extend(this._options, o); this._element = this._options.element; this._element.innerHTML = this._options.template; this._listElement = this._options.listElement || this._find(this._element, 'list'); this._classes = this._options.classes; this._button = this._createUploadButton(this._find(this._element, 'button')); this._bindCancelEvent(); this._setupDragDrop(); }; fileuploader.js - qq.FileUploaderBasic /** * Creates upload button, validates upload, but doesn't create file list or dd. */ qq.FileUploaderBasic = function(o){ this._options = { // set to true to see the server response debug: false, action: '/server/upload', params: {}, button: null, multiple: true, maxConnections: 3, // validation allowedExtensions: [], sizeLimit: 0, minSizeLimit: 0, // events // return false to cancel submit onSubmit: function(id, fileName){}, onProgress: function(id, fileName, loaded, total){}, onComplete: function(id, fileName, responseJSON){}, onCancel: function(id, fileName){}, // messages messages: { typeError: "{file} has invalid extension. Only {extensions} are allowed.", sizeError: "{file} is too large, maximum file size is {sizeLimit}.", minSizeError: "{file} is too small, minimum file size is {minSizeLimit}.", emptyError: "{file} is empty, please select files again without it.", onLeave: "The files are being uploaded, if you leave now the upload will be cancelled." }, showMessage: function(message){ alert(message); } }; qq.extend(this._options, o); // number of files being uploaded this._filesInProgress = 0; this._handler = this._createUploadHandler(); if (this._options.button){ this._button = this._createUploadButton(this._options.button); } this._preventLeaveInProgress(); };
I need displaying my image file stored from my database into the image control. I've had read some articles and watch video tutorial which there were perfectly working and I followed it but I wasn't able to make it work. The image control just displayed blank. I used Generic Handler to retrieve the image file from my database based on the articles and tutorials I've got. here are my codes below:
Generic Handler:
Code: <%@ WebHandler Language="C#" Class="ShowImage" %> using System; using System.Configuration; using System.Drawing; using System.Drawing.Imaging;
I want to make a textbox with a specific style, within this style a set of images as background parts, how can i attach these images to the custom control as whenever i take the .dll file and add it to the toolbar the images do not appear. So i tried to make them as resource files and their property as embedded in .resx file, so how to make the css style background image url to be linked to any of those image.
I have a page which displays details and a pictures of employees. The details are stored in a SQL database and the images are on the server. How can I set a default Image to display (e.g. an Image saying "Awaiting Image") if an employee picture is missing?
I can't use NullImageUrl as the Images are not stored in the database. I can't use the solution found on [URL] as an ImageField does not accept an ID attribute.
I have a service which reads an image stored in the database. I want to be able to read an image stored on the file system and return that back to the requestor.
i am having 2 imagebuttons a gridview and a button. Now if i clicked on Image button i will show a grid. Now under button click i would like to capture which image button was clicked if 1st image button is clicked i would like to some values and if 2nd one is clicked i would like to show another
I want to access one image file residing in C: of the client's machine. I know with the help of file upload control (or say input type=file), this would be easy. Due to nature of my application (Its a KIOSK application), user is not expected to select file. I am just wondering how should I implement reading file without using file upload control. I want to store this file in Images folder of server. I am beginner to WCF. Should I look towards WCF?
I have a web site that you can upload images, the image path is saved in the ImgPath field in the data database and retrieves the image and displays it in the grid view. I want to be able to delete the image from a folder within my project when I delete the record. I'm trying to delete it from the Detailsview_ItemDeleting event.
I have seen 2 methods to handle error in project. One is using try catch in every method and another is using custom page and error log file .I know both method. Which one is the best method?