.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

AsyncFileUpload: Throw Error on image size

Posted By:      Posted Date: August 25, 2010    Points: 0   Category :ASP.Net

I have an AsyncFilUpload that is used to upload  to my site. On the server side I have code that checks the width and height of the image and will only save the image if it is within the limits buit I can't figure out how to get the AsyncFileUpload control to show an error when this happens. Can anyone give me any pointers?


View Complete Post

More Related Resource Links

Reduce Image Size


How to reduce the image weight using asp.net, without lose of image quality and image pixels. For example i have an image with the size of 4 MB (3024*2045), so how to reduce the image weight ie 4 MB to 1 MB without lose quality in the same pixels ie(3024 * 2045) using asp.net.

Getting generic GDI error when trying to save resized image

Getting following error:A generic error occurred in GDI+.
Any help is appreciated.
Public Sub SaveImageFile(ByVal sourceImage As Bitmap, ByVal saveImagePath As [String], ByVal maxImageWidth As Integer)
            ' Resize if source image width is greater than the max:

            If sourceImage.Width > maxImageWidth Then
                Dim bmp As Bitmap = TryCast(sourceImage, Bitmap)
                Dim newImageHeight As Integer = CInt(Math.Truncate(sourceImage.Height * (CSng(maxImageWidth) / CSng(sourceImage.Width))))
                Dim gr As Graphics = Graphics.FromImage(bmp)

                Dim bmpnew As New Bitmap(maxImageWidth, newImageHeight)
                gr.InterpolationMode = InterpolationMode.HighQualityBicubic

                gr.DrawImage(bmpnew, 0, 0, maxImageWidth, newImageHeight)

                'code to manipulate bmpNew goes here.



how to refresh image updated with AsyncFileUpload


I've created an AsyncFileUpload device that uploads an image in ListView but it doesn't refresh on the page until the page is manually refreshed. Any ideas on how to accomplish this? This is the applicable code:

In ListView control:

<asp:UpdatePanel ID="udpPhoto" runat="server">
        <span style="text-align: center; vertical-align: middle; font-size: 7pt;">
            <br />
            <asp:Button ID="btnEPhoto" Font-Bold="False" TabIndex="160" Text="Upload/Change Photo"
                UseSubmitBehavior="False" OnClick="btnPhoto_Click" runat="server" />
            <br />
            <asp:Label ID="lblEPhoto" runat="server" Font-Bold="True" Text="Uploaded Photo:" />
            <br />
            <asp:HyperLink ID="lnkEPhoto" runat="server" BorderWidth="2px" NavigateUrl='<%# Eval("Photo_Recent") %>'
                <asp:Image runat="server" ImageUrl='<%# Eval("Photo_Recent") %>' Height="50px" ID="imgEPhoto">

Get real image size in centimeters

Hi, Im new in c# , I have an image in picturebox and draw a line connecting within two coordinates points x1, y1 and x2, y2. I wonder if there is any way of calculating the size of the line in centimeters. If i can have an example i will thank. Thanks ..  ed

PresentationHost.exe throw error: C Run-Time Error R6034

Hello, we are hosting one of our WPF (.NET 3.5 SP1) components within XBAP and thus it delivered through browser (explorer 8.0) to client. Some time clients (running explorer) receive error and this error thrown by presentetionhost.exe. The error is: C Run-Time Error R6034. We looked the error in forums and it appears related to manifest. But manifest exists for that WPF/XBAP application. Furthermore, the error does not occurs always only sometime and it not consistent it cannot be recreated on same machine for same scenario. Cleaning online app cache with mage.exe -cc does not resolve issue it continue to appear occasionally. Some comment: 1. it seems only appear at client machines, no evidence it appeared at developers machines. 2. Sometime application continues working after error box closed, but sometime it crushes. 3. May be it is not relevant but, the application accessing server side with WCF, but no error in this area. Does someone have ideas how to get rid of the error? Thanks, Pavel

error code for size limit reached

What is the error code, when the DB reaches the 10GB limit. I just wasn't ready yet to check the 36.000 error codes of SQL Server 2008 R2.

size of dropped image

hi!! i have a drag and drop handle on a canvas which displays a image on canvas when dropped a file on it: private void DropHandle(object sender, System.Windows.DragEventArgs e) { string[] arrstrFileNames = e.Data.GetData(DataFormats.FileDrop, true) as string[]; if (first) { MenuItem mnu1 = new MenuItem(); mnu1.Header = "Rotate"; mnu1.Click += new RoutedEventHandler(Rotate_Click); MenuItem mnu2 = new MenuItem(); mnu2.Click += new RoutedEventHandler(Crop_Click); mnu2.Header = "Crop"; MenuItem mnu3 = new MenuItem(); mnu3.Header = "Delete"; mnu3.Click += new RoutedEventHandler(Delete_Click); mnu.Items.Add(mnu1); mnu.Items.Add(mnu2); mnu.Items.Add(mnu3); } if (arrstrFileNames == null || arrstrFileNames.Length < 1) return; try { BitmapImage bmp = new BitmapImage(); bmp.BeginInit(); bmp.UriSource = new Uri("file:///" + arrstrFileNames[0].Replace("\\", "/")); bmp.EndInit(); Image img = new Image(); img.Source = bmp; img.Width = 300; img.Height = 300; RotateTransform rt = new RotateTransform(); img.LayoutTransform = rt; if(first==true) img.ContextMenu = mnu; first = false; assig

image error

private void dataGridView2_SelectionChanged_1(object sender, EventArgs e) { if (dataGridView2.SelectedRows.Count > 0) { pictureBox1.ImageLocation = dataGridView2.SelectedRows[0].Cells[12].Value.ToString(); this.Refresh(); imgOriginal = pictureBox1.ImageLocation; //cannot implicitly convert type string to system.image } } private Image imgOriginal; private void trackBar1_Scroll(object sender, EventArgs e) { if (trackBar1.Value > 0) { pictureBox1.Image = null; pictureBox1.Image = PictureBoxZoom(imgOriginal,new Size(trackBar1.Value, trackBar1.Value)); } } error: can not implicilty convert type string to system.drawing.image

setting inline image size with css?

I have an inline image in the header of a page that's height is being set with CSS.  The actual height of the image is slightly taller than what it's currently set to with css.  I like doing this this way because it was easier to get the image to the right size.  It avoided multiple attempts in photoshop.Is it a bad idea to set the height of an image this way?   I'm only concerned with the major modern browsers.  Are there any side effects of this that I should be aware of?

Row size error

Hello, I'm getting again row size errors: Cannot sort a row of size 32826, which is greater than the allowable maximum of 8094. Consider resubmitting the query using the ROBUST PLAN hint.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. The fields I do the operation on are 1 smalldatetime field and 11 int fields, which doesn't even get close to the maximum size, so I just don't understand what's wrong! Thanks for any help.  

BitmapImage detect image size before calling EndInit()

Hi, I'm using the following converter to create the thumbnails images: public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { try { BitmapImage bi = new BitmapImage(); string FilePath = value as string; if (null != FilePath) { bi.BeginInit(); bi.DecodePixelHeight = 80; bi.CacheOption = BitmapCacheOption.OnLoad; bi.CreateOptions = BitmapCreateOptions.DelayCreation; bi.UriSource = new Uri(FilePath); bi.EndInit(); } if (bi.CanFreeze) { bi.Freeze(); } return bi; } catch { return DependencyProperty.UnsetValue; } }   The problem is that I want to detect the image file height before generating the actual BitmapImage. In other words I need something like this:   bi.BeginInit(); if(bi.Height > 80) { bi.DecodePixelHeight = 80; } bi.CacheOption = BitmapCacheOption.OnLoad; bi.CreateOptions = BitmapCreateOptions.DelayCreation; bi.UriSource = new Uri(FilePath); bi.EndInit();   Which of cause can't be done before the EndInit() has been called. Is there is any other solution that doesn’t require creating some sort of Image class and loading the image file into it. The problem is that I'm expecting to hav

create polyline size relative to image clicked



i am creating a path geometry using polyline:


 System.Windows.Point Point1 = new System.Windows.Point(50, 10);
      System.Windows.Point Point2 = new System.Windows.Point(200, 10);
      System.Windows.Point Point3 = new System.Windows.Point(200, 100);
      System.Windows.Point Point4 = new System.Windows.Point(10, 100);
      System.Windows.Point Point5 = new System.Windows.Point(10, 50);
      System.Windows.Point Point6 = new System.Windows.Point(50, 10);
      PointCollection polygonPoints = new PointCollection();
      yellowPolyline.Points = polygonPoints;

this is a rectangle which is clipped from top-left,

actually i want to create dynamically a polyline whose size is relative to the image i click on the canvas 

and then apply than clip that image using that polyline,,so that the image looks clipped from top-left

how can

WCF To WM6 Maximum Message Size Quota Error



I am having some trouble with an error message that keeps popping up on a handheld application. It says 'The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.'

The app talks to a WCF service I've created and after googling around a bit, I discovered the MaxReceivedMessageSize value needed to be set.  However, after doing so in WCF service and setting the bindingConfiguration property to the correct binding element, the same message appears on the handheld.  The handheld app has no binding elements within the .config file and I tried adding the same binding data to this config file but the handheld crashes. What should I do?

Here's the server config binding data:


  <diagnostics wmiProviderEnabled="false">

Is there any way to get the Transfer SQL Server Objects Task to not throw error if an object already


I've asked this before but never got an answer. Is there a way to configure the Transfer SQL Server Objects Task so that it will only transfer objects that don't already exist in the destination? Or to skip over objects that already exist?

I do not want to "roll my own". I want to use the task in order to save time.

Reports rendered in R2 now give an error ; Must be non-negative and less than the size of the collec


Hi, the full error is

An error occurred during client rendering. Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

We have many reports that were working fine on the old 2008 business intelligence reporting services.  When we launched the rdls on a R2 bids server, we received the above error.

The way we fixed this was by trial and error and found a text box caption and text box expression that was too 'skinny'. We widened it vertically and it worked. No widths were negative numbers, just too 'skinny' it seemed.  Again, the text box vertical width worked fine in the old bids.

Ok, so what's our problem?  Well, we have dozens of reports now throwing this error.  The field text boxes are not all the same on the reports. We can go through each report and spend an hour trying to figure out what text box is the problem. This will be time consuming. Any patches from ms or advice how to do this quickly???


Image Uploading Error in Hosted Application at WebServer


Hi All……!

I am Working on Web Application in my Application there is one Folder Named “RestaurantImages”

My Web Application is Hosted on My Local Server and also on WebServer.

When I Upload Images, It stored in “RestaurantImages” Folder.

When I Upload Images on Local Server Hosted Application Its Working Good, but

I have a Problem When I Upload Image in my Hosted Application on WebServer its not working and

Gives an Error Like Following………

Please Help me……………!

Thanks in Advanced……..!

Controlling Page Image Size / Scale

I have created a custom master page for a WSS 3.0 site and all is working well except for the fact that I want to use the default page images that are provided, but they are too wide for the area available.  I have tried setting the table width but the width of the image seems to override that, so I would like to know if there is a way I can control the size (or better yet the scale) of the page image when it is displayed in order to have it fit within the area I have on the custom master page.

Thanks in advance,
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend