Home All Groups Group Topic Archive Search About

PostBackTrigger for Ajax cannot find FormView Button

Author
23 Oct 2007 7:59 AM
john
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

Author
24 Oct 2007 7:34 AM
Walter Wang [MSFT]
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 (waw***@online.microsoft.com, 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.
Author
24 Oct 2007 9:19 AM
john
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]"" <waw***@online.microsoft.com> wrote in message
Show quote
news:iZCfkBhFIHA.5176@TK2MSFTNGHUB02.phx.gbl...

> 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 (waw***@online.microsoft.com, 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.
>
Author
25 Oct 2007 2:34 AM
Walter Wang [MSFT]
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 (waw***@online.microsoft.com, 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.
Author
30 Oct 2007 9:28 PM
Teemu Keiski
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]"" <waw***@online.microsoft.com> wrote in message
Show quote
news:nk8xO%23qFIHA.4268@TK2MSFTNGHUB02.phx.gbl...
> 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 (waw***@online.microsoft.com, 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.
>
Author
3 Nov 2007 9:10 AM
PJ on Development
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


Show quote
On Oct 30, 6:28 pm, "Teemu Keiski" <jot***@aspalliance.com> 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]"" <waw***@online.microsoft.com> wrote in messagenews:nk8xO%23qFIHA.4***@TK2MSFTNGHUB02.phx.gbl...
>
>
>
> > 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 (waw***@online.microsoft.com, 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 -
Author
24 Oct 2007 11:40 AM
john
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]"" <waw***@online.microsoft.com> wrote in message
Show quote
news:iZCfkBhFIHA.5176@TK2MSFTNGHUB02.phx.gbl...
> 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 (waw***@online.microsoft.com, 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.
>

AddThis Social Bookmark Button