Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / May 2008

Tip: Looking for answers? Try searching our database.

File upload inside a usercontrol inside an updatepanel

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Leon Mayne - 23 May 2008 14:03 GMT
Having a bit of trouble here. I know that if you want to use a fileupload
control inside an AJAX update panel then you need to create a trigger for
the control that performs the uploading postback to the updatepanel, but the
problem is, I have an update panel inside a web usercontrol, and the
usercontrol is sitting inside an updatepanel on the host page. I therefore
can't add a trigger to the control directly, as the host page has no access
to the button within the usercontrol.

Does anyone know a way round this?
bruce barker - 23 May 2008 16:47 GMT
as you don't want the fileupload to trigger a async postback (it needs to do
a browser postback to work), just be sure its not a trigger to the panel its
inside.

-- bruce (sqlwork.com)

> Having a bit of trouble here. I know that if you want to use a fileupload
> control inside an AJAX update panel then you need to create a trigger for
[quoted text clipped - 5 lines]
>
> Does anyone know a way round this?
Leon Mayne - 27 May 2008 08:33 GMT
> as you don't want the fileupload to trigger a async postback (it needs to
> do
> a browser postback to work), just be sure its not a trigger to the panel
> its
> inside.

OK, do you know how to make just the file upload control not a trigger? The
rest of the controls in the usercontrol need to be triggers, but because
there is an extra layer between the update panel and the file upload control
I can't directly reference one from the other.

I guess I could make the control public, but wouldn't this get overwritten
as soon as the designer file is updated?
Teemu Keiski - 23 May 2008 18:24 GMT
ScriptManager.RegisterPostBackControl does the equivalent in code (you get
reference to SM with ScriptManager.GetCurrent())

"Use the RegisterPostBackControl method to register postback controls inside
an UpdatePanel control as triggers. Controls that are registered by using
this method update a whole page instead of updating only the UpdatePanel
control's content. Registering a postback control with this method outside
an UpdatePanel control has no affect because by default these controls do
not perform asynchronous postbacks"

Signature

Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

> Having a bit of trouble here. I know that if you want to use a fileupload
> control inside an AJAX update panel then you need to create a trigger for
[quoted text clipped - 5 lines]
>
> Does anyone know a way round this?
Leon Mayne - 27 May 2008 08:30 GMT
> ScriptManager.RegisterPostBackControl does the equivalent in code (you get
> reference to SM with ScriptManager.GetCurrent())
[quoted text clipped - 5 lines]
> method outside an UpdatePanel control has no affect because by default
> these controls do not perform asynchronous postbacks"

Damn, almost worked, but it looks like neither the file upload control nor a
panel implement an appropriate interface:

"Control with ID 'pnlUpload' being registered through
RegisterAsyncPostBackControl or RegisterPostBackControl must implement
either INamingContainer, IPostBackDataHandler, or IPostBackEventHandler."
Leon Mayne - 27 May 2008 10:02 GMT
>> ScriptManager.RegisterPostBackControl does the equivalent in code (you
>> get reference to SM with ScriptManager.GetCurrent())
[quoted text clipped - 12 lines]
> RegisterAsyncPostBackControl or RegisterPostBackControl must implement
> either INamingContainer, IPostBackDataHandler, or IPostBackEventHandler."

Oh wait, I registered the wrong control. I changed it to register the button
instead and it worked:

       Dim scmCurrent As ScriptManager = ScriptManager.GetCurrent(Me.Page)
       If scmCurrent IsNot Nothing Then
           scmCurrent.RegisterPostBackControl(Me.btnUpload)
       End If

Thanks Teemu.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.