Saturday, March 24, 2012

Updatepanel a fake?

Try the demo on http://atlas.asp.net/quickstart/atlas/samples/controls/UpdatePanel2_cs.aspx. Each time you hit the button a full page refresh occur. Is the updatepanel in the current state a fake?

I'm having the same experience on both the sample page and in my own test. What gives? The progress bar fires, you loose your scroll position and the back button is enabled. Sure seems like a full page refresh to me.

If you read the blog:http://www.nikhilk.net/AtlasM1.aspx, it says:

>>

<atlas:ScriptManager runat="server" id="scriptManager"EnablePartialRendering="true" />
One little attribute with lots of magic behind it. Rather than performing a real postback, we simulate a postback using the familiar XMLHTTP object (or in Atlas using the Web.Net.WebRequest class).

<<

If internally it's using XMLHTTP to call the server then you shouldn't be seeing the progress bar, loosing scroll position or having a back button enabled. My conclusion: there's a bug or UpdatePanel's ability is over-stated.


It's not a fake. Rather, it's just outdated.

If you're trying this out locally, then you have to recode few lines. For example...

Change:

<atlas:UpdatePanelrunat="server"ID="UpdatePanel1"Mode="Always">

<ContentTemplate>

<strong>

<spanstyle="text-decoration: underline">Shipping Address</span>:

</strong>

<br/>

<asp:LabelID="lblFirstLineShipping"runat="server"Font-Bold="False"></asp:Label><br/>

<asp:LabelID="lblSecondLineShipping"runat="server"></asp:Label><br/>

<asp:LabelID="lblThirdLineShipping"runat="server"></asp:Label><br/>

</ContentTemplate>

</atlas:UpdatePanel>

<asp:ButtonID="btnCopy"runat="server"Text="Same As Billing Address"OnClick="btnCopy_Click"CausesValidation="False"/>

To:

<atlas:UpdatePanelrunat="server"ID="UpdatePanel1"Mode="Always">

<ContentTemplate>

<strong>

<spanstyle="text-decoration: underline">Shipping Address</span>:

</strong>

<br/>

<asp:LabelID="lblFirstLineShipping"runat="server"Font-Bold="False"></asp:Label><br/>

<asp:LabelID="lblSecondLineShipping"runat="server"></asp:Label><br/>

<asp:LabelID="lblThirdLineShipping"runat="server"></asp:Label><br/>

<asp:ButtonID="btnCopy"runat="server"Text="Same As Billing Address"OnClick="btnCopy_Click"CausesValidation="False"/>

</ContentTemplate>

</atlas:UpdatePanel>

You could also have used <Triggers> to define this as well. Being that Atlas is a work-in-progress, it's understandable that samples may not work, but I wish someone would take care of bringing these samples up-to-date so that newbies like us can learn from them.


Sure enough, that seemed to do it. I just had to move the button and the thing being updated inside the UpdatePanel (or even in separate UpdatePanels) and it works great.

Thanks!


Yes, we haven't wuite caught up these samples. They'll be fixed up really soon :). Just to rre-iterate, the controls within a UpdatePanel will aautomatically cause an async callback but controls outside the UpdatePanel will now still perform a regular postback, unless they are tied to UpdatePanels through triggers.

No comments:

Post a Comment