Wednesday, November 18, 2009

ASP FileUpload Controller in AJAX Accordion - Stack Overflow

When working with ASP.NET, then ASP.NET AJAX, invariably you end up nesting all sorts of wacky controls inside one another.

I had been carefully avoiding putting a FileUploader inside an UpdatePanel since generally it means headaches because the FileUploader security model does not really fit into the AJAX model... maybe someday it will.

At any rate, I ended up with an FileUploader inside an Accordion inside an UpdatePanel, and of course, it stopped working since it needed a full postback, not an AJAX partial postback.

So this post on Stackoverflow.com is probably the most succinct solution to the problem I've seen and it totally makes sense:

ASP FileUpload Controller in AJAX Accordion - Stack Overflow

Here's the code:


<ajaxToolkit:AccordionPane >
<Header><asp:LinkButton ID="lbtnOption1" runat="server">Option 1</asp:LinkButton></Header>
<Content>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
/* Put HtmlInputFile and upload button here*/
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnUpload" />
</Triggers></asp:UpdatePanel>
</Content>
</ajaxToolkit:AccordionPane>

1 comment:

Unknown said...

Great post! This blog is a great source of information which is very useful for me. Thanks for showing up such fabulous information.

Web Design Company