Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > PostBackTrigger for Ajax cannot find FormView Button

Reply
Thread Tools

PostBackTrigger for Ajax cannot find FormView Button

 
 
john
Guest
Posts: n/a
 
      10-23-2007
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>
<aspostBackTrigger 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


 
Reply With Quote
 
 
 
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      10-24-2007
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/documentatio...lOverview.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 ((E-Mail Removed), 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.

 
Reply With Quote
 
 
 
 
john
Guest
Posts: n/a
 
      10-24-2007
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(AttachButto n), 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]"" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> 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/documentatio...lOverview.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 ((E-Mail Removed), 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.
>



 
Reply With Quote
 
john
Guest
Posts: n/a
 
      10-24-2007
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>
<aspostBackTrigger 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]"" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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/documentatio...lOverview.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 ((E-Mail Removed), 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.
>



 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      10-25-2007
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 ((E-Mail Removed), 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.

 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      10-30-2007
Walter, I bet he means this example on ASP.NEt Ajax's own docs:
http://asp.net/AJAX/Documentation/Li...ckTrigger.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]"" <(E-Mail Removed)> wrote in message
news:nk8xO%(E-Mail Removed)...
> 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 ((E-Mail Removed), 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.
>



 
Reply With Quote
 
PJ on Development
Guest
Posts: n/a
 
      11-03-2007
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/ar...yncupload.html

Regards,

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


On Oct 30, 6:28 pm, "Teemu Keiski" <(E-Mail Removed)> wrote:
> Walter, I bet he means this example on ASP.NEt Ajax's own docs:http://asp.net/AJAX/Documentation/Li...b_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]"" <(E-Mail Removed)> wrote in messagenews:nk8xO%(E-Mail Removed). 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 ((E-Mail Removed), 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 -



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Button.Click event doesn't fire when clicking button in formView.InsertItemTemplate Andy B. ASP .Net 0 11-25-2009 03:27 PM
PostBackTrigger Sam ASP .Net 0 08-27-2009 03:08 PM
Make nested control PostBackTrigger gsauns ASP .Net 0 12-07-2007 02:16 PM
AJAX, FileUpload and PostBackTrigger pcman ASP .Net 0 08-01-2007 08:28 PM
AJAX IDE and AJAX TOOL--The Release of JoyiStar AJAX WebShop 3 Beta minnie Java 1 12-13-2006 06:29 AM



Advertisments