It seems to me that I read an article says when I use an UpdatePanel not all events are rising.
Help me find the list of the events that are rising with UpdatePanel.
Thank you in advance,
Igor
Hi,
when an UpdatePanel performs a partial postback, the whole page lifecycle is executed, thus all the server-side events are being raised.
Garbin:
when an UpdatePanel performs a partial postback, the whole page lifecycle is executed, thus all the server-side events are being raised.
Thank you.
Garbin:
when an UpdatePanel performs a partial postback, the whole page lifecycle is executed, thus all the server-side events are being raised.
Thank you.
Luckily the ASP.NET team put a funky ittle feature into Atlas which will let you detect if you're in a Partial render or not.
Here's some code I put together to show this in action and how you can use it: -
1<%@. Page Language="C#" AutoEventWireup="true" CodeFile="PostBackType.aspx.cs" Inherits="PostBackType" %>23<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">4<html xmlns="http://www.w3.org/1999/xhtml">5<head runat="server">6 <title>Untitled Page</title>7</head>8<body>9 <form id="form1" runat="server">10 <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />11 <div>12 <asp:Button ID="MyNormalButton" runat="server" Text="Cause Normal Postback" />13 <atlas:UpdatePanel ID="Panel1" runat="server">14 <ContentTemplate>15 <asp:Button ID="MyButton" runat="server" Text="Cause Partial Render Postback" />16 <h1 id="MyMessage" runat="server"></h1>17 </ContentTemplate>18 </atlas:UpdatePanel>19 </div>20 </form>2122 <script type="text/xml-script">23 <page xmlns:script="http://schemas.microsoft.com/xml-script/2005">24 <references>25 </references>26 <components>27 </components>28 </page>29 </script>30</body>31</html>
Then the C#
1using System;2using System.Data;3using System.Configuration;4using System.Web;5using System.Web.Security;6using System.Web.UI;7using System.Web.UI.WebControls;8using System.Web.UI.WebControls.WebParts;9using System.Web.UI.HtmlControls;10using Performance;111213public partialclass PostBackType : System.Web.UI.Page14{15protected void Page_Load(object sender, EventArgs e)16 {17 SetMessage();18 }1920private void SetMessage()21 {22switch (GetPostBackType())23 {24case PostBack.NotPostBack:25 MyMessage.InnerText = ("Not a Postback");26break;27case PostBack.NormalPostBack:28 MyMessage.InnerText = ("Normal Postback");29break;30case PostBack.PartialRenderPostBack:31 MyMessage.InnerText = ("Partial Render");32break;33 }34 }3536private PostBack GetPostBackType()37 {38if (!Page.IsPostBack)39 {40return PostBack.NotPostBack;41 }42else if ((Page.IsPostBack) && (!ScriptManager1.IsInPartialRenderingMode))43 {44return PostBack.NormalPostBack;45 }46else if ((Page.IsPostBack) && (ScriptManager1.IsInPartialRenderingMode))47 {48return PostBack.PartialRenderPostBack;49 }50else51 {52throw new System.NotSupportedException("This kind of Postback is not currently catered for");53 }54 }55}
NICE!!Thanks for the excellent illustration.
and for those of you doing this from a usercontrol, the code would change a little to something like this:
Dim
tempControl2As System.Web.UI.ScriptManagertempControl2 =
CType(Page.FindControl("ScriptManager1"), System.Web.UI.ScriptManager)IfNot tempControl2.IsInAsyncPostBackThen
No comments:
Post a Comment