By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,318 Members | 2,107 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,318 IT Pros & Developers. It's quick & easy.

File upload inside a usercontrol inside an updatepanel

P: n/a
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?

Jun 27 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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)
"Leon Mayne" wrote:
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?
Jun 27 '08 #2

P: n/a
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"

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

"Leon Mayne" <le**@rmvme.mvps.orgwrote in message
news:92**********************************@microsof t.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
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?

Jun 27 '08 #3

P: n/a
"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:eb**************@TK2MSFTNGP04.phx.gbl...
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"
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."

Jun 27 '08 #4

P: n/a
"bruce barker" <br*********@discussions.microsoft.comwrote in message
news:C5**********************************@microsof t.com...
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?

Jun 27 '08 #5

P: n/a
"Leon Mayne" <le**@rmvme.mvps.orgwrote in message
news:3A**********************************@microsof t.com...
"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:eb**************@TK2MSFTNGP04.phx.gbl...
>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"

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."
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.

Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.