PostBackTrigger for Ajax cannot find FormView Button

Discussion in 'ASP .Net Web Controls' started by john, Oct 23, 2007.

  1. john

    john Guest

    This Error on page load attempt:
    A control with ID 'AttachButton' could not be found for the trigger in
    UpdatePanel 'UpdatePanel1'.
    Condition: File Upload Control inside of and Ajax UpdatePanel, which is
    inside of a FormView Insert Template. File Upload Control needs this Trigger
    according documentation inside of UpdatPanel for an Attach Button to do a
    Post Back.

    I assume the error is because the Button does not Exist until I enter the
    Insert Template View, but the Trigger has to be outside the Content
    Template.

    Question is how to avoid the Trigger error until I can get into the FormView
    Template; if that is the problem as I descibed it?

    Maybe I Should just name the Item Template ButtonNew with that ID just so it
    sees it or have a dummy button with that ID but not Enabled?


    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <Triggers>
    <asp:postBackTrigger ControlID="AttachButton" />
    </Triggers>
    <ContentTemplate>
    <asp:FormView ID="FormView2" runat="server" DataKeyNames="KeyID"
    DataSourceID="SqlDataSourceAdd" Width="775px">
    <EditItemTemplate>
    </EditItemTemplate>
    <InsertItemTemplate>
    <asp:Button ID="AttachButton" runat="server" CausesValidation="False"
    OnClick="Button1_Click"
    Text="Attach Uploaded File" />
    <asp:FileUpload ID="FileUpload1" runat="server" Width="500px" />

    </InsertItemTemplate>
    <ItemTemplate>
    <asp:Button ID="ButtonNew" runat="server" CommandName="New"
    Text="New" Width="75px" />

    </ItemTemplate>
    </asp:FormView>
    </ContentTemplate>
    </asp:UpdatePanel>


    Thanks
    John
     
    john, Oct 23, 2007
    #1
    1. Advertising

  2. Hi John,

    FileUpload is not compatible with UpdatePanel:

    #ASP.NET AJAX > Overview > The UpdatePanel and UpdateProgress Controls >
    UpdatePanel Control Overview
    http://www.asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx
    <quote>
    Controls that Are Not Compatible with UpdatePanel Controls

    The following ASP.NET controls are not compatible with partial-page
    updates, and are therefore not supported inside an UpdatePanel control:

    TreeView and Menu controls.

    Web Parts controls. For more information, see ASP.NET Web Parts Controls.

    FileUpload controls when they are used to upload files as part of an
    asynchronous postback.
    </quote>

    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Walter Wang [MSFT], Oct 24, 2007
    #2
    1. Advertising

  3. john

    john Guest

    Yes, I am aware of that, according to documentation the work around is the
    postbacktrigger as I have set up. The other workaround method recommended
    is:
    Call ScriptManager1.RegisterPostBackControl(AttachButton), Which I do as
    Follows:
    Dim bu As Button = sender.FindControl("AttachButton")
    Call ScriptManager1.RegisterPostBackControl(bu)

    The problem I am having is that neither of these examples, which are
    solutions that are recommended, seem to work within a FormView Control. The
    Call ScriptManager1.RegisterPostBackControl(bu) is recommended for dynamic
    conditions like a Formview where the AttachButton does not exist and unknown
    to the system until you enter the InsertTemplate mode. Therefore I have to
    use the FindControl on the DataBound event, which it does find the
    AttachButton for the Call ScriptManager1.RegisterPostBackControl(bu).

    When I then Click the AttachButton and do the HasFile test on the FileUpload
    Control, it still returns False, even though the Condition is True.

    They say this should work but I must be implementing it wrong somehow and
    that is what I am looking to solve?

    Thanks

    TJ

    ""Walter Wang [MSFT]"" <> wrote in message
    news:...

    > Hi John,
    >
    > FileUpload is not compatible with UpdatePanel:
    >
    > #ASP.NET AJAX > Overview > The UpdatePanel and UpdateProgress Controls >
    > UpdatePanel Control Overview
    > http://www.asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx
    > <quote>
    > Controls that Are Not Compatible with UpdatePanel Controls
    >
    > The following ASP.NET controls are not compatible with partial-page
    > updates, and are therefore not supported inside an UpdatePanel control:
    >
    > TreeView and Menu controls.
    >
    > Web Parts controls. For more information, see ASP.NET Web Parts Controls.
    >
    > FileUpload controls when they are used to upload files as part of an
    > asynchronous postback.
    > </quote>
    >
    > Regards,
    > Walter Wang (, remove 'online.')
    > Microsoft Online Community Support
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
     
    john, Oct 24, 2007
    #3
  4. john

    john Guest

    Found odd workaround for FormView inside of UpdatePanel, here is the method
    with the Datasource omitted:
    They key to it working appears to be having the "New" Button on the Item
    Template with the same Trigger ID as the
    "Attach Uploaded File" Button on the Insert Template, along with the 3rd
    Transparent Button outside of the FormView.

    It seems to expose the AttachButton ID as a submit Button to act as a
    Trigger for the PostBack within
    the FormView & UpdatePanel; anyway it works, even inside of a MasterPage.

    Any thought's welcome to my better understanding this are welcome?

    Thanks
    John

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitled Page</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <Triggers>
    <asp:postBackTrigger ControlID="FormView2_AttachButton" />
    </Triggers>
    <ContentTemplate>
    <asp:FormView ID="FormView2" runat="server" DataKeyNames="KeyID"
    DataSourceID="SqlDataSourceAdd" Width="775px" >
    <EditItemTemplate>
    </EditItemTemplate>
    <InsertItemTemplate>
    <asp:Button ID="AttachButton" runat="server" CausesValidation="False"
    OnClick="Button1_Click"
    Text="Attach Uploaded File" />
    <asp:FileUpload ID="FileUpload1" runat="server" Width="500px" />

    </InsertItemTemplate>
    <ItemTemplate>
    <asp:Button ID="AttachButton" runat="server"
    CommandName="New" Text="New" Width="75px" />

    </ItemTemplate>
    </asp:FormView>
    <asp:Button ID="FormView2_AttachButton" runat="server"
    BackColor="Transparent" BorderColor="Transparent" BorderStyle="None"
    Enabled="False" />
    </ContentTemplate>
    </asp:UpdatePanel>

    </div>
    </form>
    </body>
    </html>

    ""Walter Wang [MSFT]"" <> wrote in message
    news:...
    > Hi John,
    >
    > FileUpload is not compatible with UpdatePanel:
    >
    > #ASP.NET AJAX > Overview > The UpdatePanel and UpdateProgress Controls >
    > UpdatePanel Control Overview
    > http://www.asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx
    > <quote>
    > Controls that Are Not Compatible with UpdatePanel Controls
    >
    > The following ASP.NET controls are not compatible with partial-page
    > updates, and are therefore not supported inside an UpdatePanel control:
    >
    > TreeView and Menu controls.
    >
    > Web Parts controls. For more information, see ASP.NET Web Parts Controls.
    >
    > FileUpload controls when they are used to upload files as part of an
    > asynchronous postback.
    > </quote>
    >
    > Regards,
    > Walter Wang (, remove 'online.')
    > Microsoft Online Community Support
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
     
    john, Oct 24, 2007
    #4
  5. Hi John,

    Thanks for your reply. Could you please tell me where is the documentation
    on the workaround about using FileUpload in UpdatePanel? Thanks.


    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Walter Wang [MSFT], Oct 25, 2007
    #5
  6. john

    Teemu Keiski Guest

    Walter, I bet he means this example on ASP.NEt Ajax's own docs:
    http://asp.net/AJAX/Documentation/Live/mref/T_System_Web_UI_PostBackTrigger.aspx

    on bottom:

    "
    The following example shows how to declaratively define a PostBackTrigger
    control for an UpdatePanel control. In the panel, a FileUpload control
    enables users to upload a file. Users must first check whether the file to
    upload exists. The Button control that calls the event handler to check the
    file name causes an asynchronous postback. However, the Button control that
    uploads the file is registered as a PostBackTrigger, because files cannot be
    uploaded asynchronously.

    "

    PostBackTrigger makes it possible to upload the file since it causes normal
    postback.

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

    ""Walter Wang [MSFT]"" <> wrote in message
    news:nk8xO%...
    > Hi John,
    >
    > Thanks for your reply. Could you please tell me where is the documentation
    > on the workaround about using FileUpload in UpdatePanel? Thanks.
    >
    >
    > Regards,
    > Walter Wang (, remove 'online.')
    > Microsoft Online Community Support
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
     
    Teemu Keiski, Oct 30, 2007
    #6
  7. Greetings,

    I'm just writing to announce that I've just uploaded an Asynchronous
    Upload Control in my website, and I'd like some feedback about it.

    The control was built for a project I'm currently working on and it's
    pretty self explanatory.

    Please take a look and feel free to leave comments about it.

    The controls is at http://pjondevelopment.50webs.com/articles/asyncupload.html

    Regards,

    Paulo Santos
    http://pjondevelopment.50webs.com


    On Oct 30, 6:28 pm, "Teemu Keiski" <> wrote:
    > Walter, I bet he means this example on ASP.NEt Ajax's own docs:http://asp.net/AJAX/Documentation/Live/mref/T_System_Web_UI_PostBackT...
    >
    > on bottom:
    >
    > "
    > The following example shows how to declaratively define a PostBackTriggercontrolfor an UpdatePanelcontrol. In the panel, a FileUploadcontrol
    > enables users touploada file. Users must first check whether the file touploadexists. The Buttoncontrolthat calls the event handler to check the
    > file name causes an asynchronous postback. However, the Buttoncontrolthat
    > uploads the file is registered as a PostBackTrigger, because files cannot be
    > uploaded asynchronously.
    >
    > "
    >
    > PostBackTrigger makes it possible touploadthe file since it causes normal
    > postback.
    >
    > --
    > Teemu Keiski
    > AspInsider, ASP.NET MVPhttp://blogs.aspadvice.com/jotekehttp://teemukeiski.net
    >
    > ""Walter Wang [MSFT]"" <> wrote in messagenews:nk8xO%...
    >
    >
    >
    > > Hi John,

    >
    > > Thanks for your reply. Could you please tell me where is the documentation
    > > on the workaround about using FileUpload in UpdatePanel? Thanks.

    >
    > > Regards,
    > > Walter Wang (, remove 'online.')
    > > Microsoft Online Community Support

    >
    > > ==================================================
    > > When responding to posts, please "Reply to Group" via your newsreader so
    > > that others may learn and benefit from your issue.
    > > ==================================================

    >
    > > This posting is provided "AS IS" with no warranties, and confers no
    > > rights.- Hide quoted text -

    >
    > - Show quoted text -
     
    PJ on Development, Nov 3, 2007
    #7
    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. pcman
    Replies:
    0
    Views:
    1,070
    pcman
    Aug 1, 2007
  2. =?Utf-8?B?RQ==?=
    Replies:
    0
    Views:
    457
    =?Utf-8?B?RQ==?=
    Sep 11, 2007
  3. gsauns

    Make nested control PostBackTrigger

    gsauns, Dec 7, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    585
    gsauns
    Dec 7, 2007
  4. Sam

    PostBackTrigger

    Sam, Aug 27, 2009, in forum: ASP .Net
    Replies:
    0
    Views:
    1,117
  5. Andy B.
    Replies:
    0
    Views:
    923
    Andy B.
    Nov 25, 2009
Loading...

Share This Page