File upload inside a usercontrol inside an updatepanel

Discussion in 'ASP .Net' started by Leon Mayne, May 23, 2008.

  1. Leon Mayne

    Leon Mayne Guest

    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?
     
    Leon Mayne, May 23, 2008
    #1
    1. Advertising

  2. Leon Mayne

    bruce barker Guest

    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?
    >
     
    bruce barker, May 23, 2008
    #2
    1. Advertising

  3. Leon Mayne

    Teemu Keiski Guest

    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" <> wrote in message
    news:...
    > 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?
     
    Teemu Keiski, May 23, 2008
    #3
  4. Leon Mayne

    Leon Mayne Guest

    "Teemu Keiski" <> wrote in message
    news:...
    > 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."
     
    Leon Mayne, May 27, 2008
    #4
  5. Leon Mayne

    Leon Mayne Guest

    "bruce barker" <> wrote in message
    news:...
    > 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?
     
    Leon Mayne, May 27, 2008
    #5
  6. Leon Mayne

    Leon Mayne Guest

    "Leon Mayne" <> wrote in message
    news:...
    > "Teemu Keiski" <> wrote in message
    > news:...
    >> 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.
     
    Leon Mayne, May 27, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nail
    Replies:
    0
    Views:
    1,563
  2. Replies:
    3
    Views:
    492
    Rob Meade
    Aug 8, 2007
  3. Bjorn Sagbakken

    Upload File in an UpdatePanel (AJAX)

    Bjorn Sagbakken, Sep 25, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    406
    Bjorn Sagbakken
    Sep 25, 2007
  4. Bjorn Sagbakken
    Replies:
    2
    Views:
    558
    Bjorn Sagbakken
    Sep 26, 2007
  5. Nathan Sokalski
    Replies:
    1
    Views:
    597
    miher
    Jun 15, 2009
Loading...

Share This Page