Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 2nd, 2009, 06:07 PM
Authorized User
 
Join Date: Apr 2008
Posts: 26
Thanks: 6
Thanked 0 Times in 0 Posts
Default Wrox-Blog: Update Panel Question

Hi,

I am adding more functionality to Wrox blog engine. One of the ideas I had was to let the user upload pictures and manage them and these pictures to be inserted into blogs..

I have an issue related to update panel.. May be I don't fully understand how update panels work or may be I am doing some mistakes without knowing what is going on... I have a panel within an update panel where updatemode set to "conditional" as piece of data in the panel is dynamically updated (drop down list is updated) when something happens in another panel of the web page.This part of the code works fine. But the issue here is within conditional update panel, I have a file upload control. I simply wanted to make sure if user clicks the submit button without having a file selected then prompts an error message to say.. "please select a file to upload:"

If I remove the update panel and test code...it works fine.. I see the error message pops-up.. but as soon as update panel is added & I hit the submit button... following error comes-up..."Object reference not set to an instance of an object"...after searching the web for this error. I thought declaring the file upload control in the code would clear out this error. but it didn't..

Any input would be appreciated

Here is the example code.. ( I clean-up the code..just to isolate the issue and for this posting...)

<asp:UpdatePanel ID="UpdatePanelUserPhotoUpload" runat="server" UpdateMode="Conditional" RenderMode="inline">
<ContentTemplate>
<asp:Panel ID="PanelUserPhotoUpload" runat="server">
<asp:FileUpload ID="Ad_Picture2" runat="server" />

<asp:DropDownList cssClass="dropdown_list_small" skinid="right" AppendDataBoundItems="true" ID="drp_PhotoCategories" runat="server">
</asp:DropDownList>

<asp:Button ID="btn_AddUserPhotos"
ValidationGroup="val_photogroup"
runat="server"
Text="Add User Photo" OnClick="btn_AddUserPhotos_Click" />
</asp:Panel>

</ContentTemplate>
</asp:UpdatePanel>
================================================== ==

Code:

Protected Sub btn_AddUserPhotos_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If Ad_Picture2.PostedFile.ContentLength = 0 Then
ShowPhotoUploadMessage("Please select image to upload")
Exit Sub
End If
End Sub

Last edited by norman001; March 2nd, 2009 at 06:12 PM..
 
Old March 2nd, 2009, 06:23 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

There are (documented) issues with the FileUpload control inside an UpdatePanel. For more info:

http://forums.asp.net/p/1105208/1689084.aspx

http://www.asp.net/AJAX/Documentatio...lOverview.aspx (section "Controls that Are Not Compatible with UpdatePanel Controls " near the end)

http://www.google.com/search?hl=en&q...Upload&aq=f&oq=

http://www.muraton.net/post/2008/01/...datePanel.aspx (explains how to do a full postback)

http://geekswithblogs.net/ranganh/ar....net-ajax.aspx (with links to an iframe workaround)

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old March 2nd, 2009, 09:15 PM
Authorized User
 
Join Date: Apr 2008
Posts: 26
Thanks: 6
Thanked 0 Times in 0 Posts
Default Wrox-Blog: Update Panel Question

Hi,

After searching bit more...this article helped me to solve the issue. I just added following 3 lines to the code..
(http://www.codeproject.com/KB/ajax/s...jaxupload.aspx)

<Triggers>
<asp:PostBackTrigger ControlID="Button1" />
</Triggers>

I learned something new today..

Thank you!

Last edited by norman001; March 2nd, 2009 at 09:17 PM.. Reason: missing title..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrox Blog editor image question norman001 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 February 23rd, 2009 03:40 AM
Wrox Blog - Stored Procedure Update - Count Comments norman001 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 12 February 12th, 2009 01:08 AM
Wrox Blog Question - LinkButton norman001 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 14 February 7th, 2009 03:03 PM
Masterpage Update Panel Question jazzcatone ASP.NET 2.0 Basics 1 June 14th, 2007 09:20 AM
Wrox Blog: Viewing individual blog entries Tawanda BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 7 May 7th, 2007 12:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.