Tuesday, November 24, 2009

Page_Load event firing twice

This has not been a really great week for me and ASP.NET...

I ran into this problem after fixing the other problem:

Page_Load event is firing twice - ExtremeExperts

So with that information, coupled with this information:

Stackoverflow.com - ASP.NET Page.OnLoad executes twice

...and this item from the Microsoft KB:

How to use the AutoEventWireup attribute in an ASP.NET Web Form by using Visual C# .NET

...I was able to solve this double-page-load problem since I was, in fact, wiring up events in a page that had AutoEventWireup set to "true" and the Page_Load was getting fired twice. Awesome.

Anyway, another bullet dodged.

Dynamically Created LinkButtons and UpdatePanel Woes

Check out my pain as described in this ASP.NET forum post:

Button command not working inside an UpdatePanel - ASP.NET Forums

Totally ridiculous how much work I had to do to get this function working.

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>