Solved

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

Posted on 2012-03-27
1
494 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn how to dynamically set the form action using jQuery.
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).

860 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