Solved

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

Posted on 2012-03-27
1
499 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

696 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