• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 521
  • Last Modified:

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

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
morant
Asked:
morant
1 Solution
 
Lalit ChandraCommented:
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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now