Solved

Using an asp:UpdatePanel to Trigger vb code to save picture into a database

Posted on 2012-03-27
1
484 Views
Last Modified: 2012-03-27
Hi,
I have a button and an input type=file box.  This uses some vb code to convert a picture so I can save it into a database image column.  This all works fine.  If I add an update panel around it with a asp:PostBackTrigger again it works fine but is still jumping for the user.  If I use a asp:AsyncPostBackTrigger it breaks on the following line.

intImageSize = File2.PostedFile.ContentLength

This is the error I recieve.

System.NullReferenceException was unhandled by user code
  Message=Object reference not set to an instance of an object.
  Source=App_Web_kxfoj2ur
  StackTrace:
       at Create_Brief.Button4_Click(Object sender, EventArgs e) in C:\Documents and Settings\newcoc01\My Documents\Visual Studio 2010\WebSites\20120327\Create_Brief.aspx.vb:line 550
       at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
       at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException:

 Protected Sub Button4_Click(sender As Object, e As System.EventArgs) Handles Button4.Click

        '**** Resize image section ****  File2
        Dim strImageType As String
        Dim intImageSize As Int64
        Dim ImageStream As Stream

        ' Gets the Size of the Image
        intImageSize = File2.PostedFile.ContentLength

        ' Gets the Image Type
        strImageType = File2.PostedFile.ContentType

        ' Reads the Image
        ImageStream = File2.PostedFile.InputStream

Open in new window


Does anyone know why this happens and how I can get this working?
0
Comment
Question by:morant
1 Comment
 
LVL 7

Accepted Solution

by:
Lalit Chandra earned 500 total points
ID: 37772818
This problem is somewhat well documented, the update panel is listed as not working with certain controls.

File upload, and tree view being 2 of the biggies.

IN any case, one solution is available on code project:

http://www.codeproject.com/useritems/simpleajaxupload.asp

if you look around the forums and google, you can read more about the problem if your interested, but the code project solution should get you started.

Hope this will guide you to solve your problem.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now