File upload inside a usercontrol inside an updatepanel

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leon Mayne

    File upload inside a usercontrol inside an updatepanel

    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?

  • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

    #2
    RE: File upload inside a usercontrol inside an updatepanel

    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?
    >

    Comment

    • Teemu Keiski

      #3
      Re: File upload inside a usercontrol inside an updatepanel

      ScriptManager.R egisterPostBack Control does the equivalent in code (you get
      reference to SM with ScriptManager.G etCurrent())

      "Use the RegisterPostBac kControl 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



      "Leon Mayne" <leon@rmvme.mvp s.orgwrote in message
      news:9229A2DC-CD31-4459-B02A-4DE0F1A95743@mi crosoft.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?

      Comment

      • Leon Mayne

        #4
        Re: File upload inside a usercontrol inside an updatepanel

        "Teemu Keiski" <joteke@aspalli ance.comwrote in message
        news:eboLbnPvIH A.2188@TK2MSFTN GP04.phx.gbl...
        ScriptManager.R egisterPostBack Control does the equivalent in code (you get
        reference to SM with ScriptManager.G etCurrent())
        >
        "Use the RegisterPostBac kControl 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
        RegisterAsyncPo stBackControl or RegisterPostBac kControl must implement
        either INamingContaine r, IPostBackDataHa ndler, or IPostBackEventH andler."

        Comment

        • Leon Mayne

          #5
          Re: File upload inside a usercontrol inside an updatepanel

          "bruce barker" <brucebarker@di scussions.micro soft.comwrote in message
          news:C50DBA6D-117B-462A-A0DC-7013B893F634@mi crosoft.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?

          Comment

          • Leon Mayne

            #6
            Re: File upload inside a usercontrol inside an updatepanel

            "Leon Mayne" <leon@rmvme.mvp s.orgwrote in message
            news:3AAE7272-B042-4A4C-8628-0412CE8F29A7@mi crosoft.com...
            "Teemu Keiski" <joteke@aspalli ance.comwrote in message
            news:eboLbnPvIH A.2188@TK2MSFTN GP04.phx.gbl...
            >ScriptManager. RegisterPostBac kControl does the equivalent in code (you
            >get reference to SM with ScriptManager.G etCurrent())
            >>
            >"Use the RegisterPostBac kControl 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
            RegisterAsyncPo stBackControl or RegisterPostBac kControl must implement
            either INamingContaine r, IPostBackDataHa ndler, or IPostBackEventH andler."
            Oh wait, I registered the wrong control. I changed it to register the button
            instead and it worked:

            Dim scmCurrent As ScriptManager = ScriptManager.G etCurrent(Me.Pa ge)
            If scmCurrent IsNot Nothing Then
            scmCurrent.Regi sterPostBackCon trol(Me.btnUplo ad)
            End If

            Thanks Teemu.

            Comment

            Working...