Solved

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

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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 …

759 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

19 Experts available now in Live!

Get 1:1 Help Now