large value of AsyncPostBackTimeout causes Sys.WebForms.PageRequestManagerTimeoutException - asp.net

I use UpdatePanel with large async timeout value:
<asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="3600000" />
<asp:UpdatePanel UpdateMode="Conditional" RenderMode="Block" runat="server" ID="UpdatePanel1">
<ContentTemplate>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="RunButton" />
</Triggers>
</asp:UpdatePanel>
It throws 'Sys.WebForms.PageRequestManagerTimeoutException.' instantly.
Setting it to smaller value ie. 1200000 fixes it but why?

Related

Make any button on the page as a trigger for an asp.net UpdatePanel other than its sibling or child postback controls

Consider the following code fragment:
<div>
<asp:Button runat="server" ID="trickyUPTrigger" Text="Tricky Update" />
<div>
<asp:Button runat="server" ID="normalUPTrigger" OnClick="normalUPTrigger_Click" Text="Normal Update" />
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="normalUPTrigger" />
</Triggers>
<ContentTemplate>
<asp:Label runat="server" ID="changeableLabel" Text="Change me"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
Now make the button with ID of trickyUPTrigger as the trigger of the UpdatePanel. Or, devise a mechanism (probably... using javascript?) so that when this button is clicked UpdatePanel updates without full page postback.
If you want to update the UpdatePanel when clicking on trickyUPTrigger, you can add that button to the triggers list:
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="normalUPTrigger" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="trickyUPTrigger" EventName="Click" />
</Triggers>
<ContentTemplate>
...
</ContentTemplate>
</asp:UpdatePanel>
UPDATE
You asked some code examples showing cases with naming containers, a concept that comes into play for databound controls with item templates, like the GridView and the ListView, and for user controls. In the examples below, I use a ListView, where each item is a separate naming container.
If you wanted to trigger an update of your panel from a button in a ListView item template, the trigger would not be found at runtime, and an exception would occur:
<asp:ListView ID="lstView" runat="server">
<ItemTemplate>
<asp:Button ID="anotherTrigger" runat="server" Text="This trigger cannot be found!" OnClick="anotherTrigger_Click" />
</ItemTemplate>
</asp:ListView>
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="anotherTrigger" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
The reverse case (the UpdatePanel in the ListView item template, the trigger button outside of the ListView) does work, according to my tests, which seems to contradict the note that you mention in your comment:
<asp:ListView ID="lstView" runat="server">
<ItemTemplate>
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="anotherTrigger" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</ItemTemplate>
</asp:ListView>
<asp:Button ID="anotherTrigger" runat="server" Text="This trigger works!" OnClick="anotherTrigger_Click" />
Finally, the case where the UpdatePanel and the trigger button are both in the ListView item template also works:
<asp:ListView ID="lstView" runat="server">
<ItemTemplate>
<asp:Button ID="anotherTrigger" runat="server" Text="This trigger works!" OnClick="anotherTrigger_Click" />
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="anotherTrigger" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</ItemTemplate>
</asp:ListView>
You can notice that I set UpdateMode="Conditional" for the panel in this last example. With this setting, the panel is updated only by its own triggers. If the attribute is set to UpdateMode="Always", the panel is updated not only by his own triggers but also by the triggers of the other UpdatePanels in the page. The default value is UpdateMode="Always" (as in your code sample).

how to refresh updatePanel with asp.net Timer control only once ?

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" Interval="100" OnTick="Timer1_Tick"></asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
// my code is here
</ContentTemplate>
</asp:UpdatePane>
above code refresh update panel in the period time.

Why does a masterpage's UpdatePanel trigger event also trigger an UpdatePanel in a content page?

I have the following updatepanel in the masterpage:
<asp:UpdatePanel runat="server" id="pnlHeartBeat" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="HeartBeat" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Timer runat="server" id="HeartBeat" Interval="180000" OnTick="Heartbeat_OnTick"></asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
This runs fine no matter where I am in the site... right up to the point I navigate to a content page with another updatepanel, after which whenever the masterpage's updatepanel is triggered, so will the content page's updatepanel.
Here's a content page updatepanel:
<asp:UpdatePanel ID="ajaxColumnGroups" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="cboxAllorNone" EventName="CheckedChanged" />
</Triggers>
<contenttemplate>
<dx:ASPxCheckBox ID="cboxAllorNone" runat="server" text="Select/Deselect All" OnCheckedChanged="cboxAllorNone_CheckChanged" autopostback="true"></dx:ASPxCheckBox>
<dx:ASPxPageControl runat="server" id="tabColumnGroups" ActiveTabIndex="0"></dx:ASPxPageControl>
</contenttemplate>
</asp:UpdatePanel>
How can I stop this behavior?
Thanks

gridview that is updated frequently

I have a ASP.NET gridview that shows some entries from the database. The entries need to be updated very frequently (if a modification occurs on the database, it should be reflected in the asp.net website within at most 3seconds).
The solution I am thinking about is to put the gridview inside an update panel and refresh the page every 3 seconds. Is there a better alternative?
By using Timer in the update panel u can perform that update operation.For example ..
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="10000">
</asp:Timer>
</div>
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="UpdatePanel1 not refreshed yet."></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label2" runat="server" Text="UpdatePanel2 not refreshed yet."></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</form>
instead of label control u can use gridview.

ASP timer Control is refreshing the whole page?

I have a ASP timer control which is supposed to run every three minutes. Although I kept the Timer control in an update panel, it is refreshing the whole page every time it runs.
Is there any it only refresh the particular section of the page, not the whole page?
<div>
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" Interval="300000" >
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<asp:Timer runat="server" id="UpdateTimer" interval="200" ontick="function" />
<asp:UpdatePanel runat="server" id="TimedPanel" updatemode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger controlid="UpdateTimer" eventname="Tick" />
</Triggers>
<ContentTemplate>
<asp:Label runat="server" id="label1" />
<asp:TextBox ID="textbox1" runat="server"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" Interval="300000">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
you need to use UpdatePanel Triggers. Conditional Update Panels with triggers, and msdn source. Updatepanel with Triggers
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" Interval="300000"> </asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
Use update panel and add all the control's inside update panel which you don't want to be refreshed or postback by any event

Resources