Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdatepanel gives full postback instead of asyncpostback
    primarykey
    data
    text
    <p>I have run into what seems to be a very famous problem: My updatepanel fires a full postback instead of a async postback. The normal solution is to give all controls you add dynamically an ID, which I have done, but I still get a full postback instead of my async postback...</p> <p>Here's the code:</p> <p>HTML:</p> <pre><code>&lt;asp:UpdatePanel ID="ItemsUpdatePanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="False"&gt; &lt;Triggers&gt; &lt;/Triggers&gt; &lt;ContentTemplate&gt; &lt;asp:ListView ID="PlayerItems" runat="server" GroupItemCount="5" onitemdatabound="PlayerItems_ItemDataBound"&gt; &lt;LayoutTemplate&gt; ... Listview stuff ... &lt;/asp:ListView&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p>The interesting part is the C# code behind (method PlayerItems_ItemDataBound), which is like the following:</p> <pre><code> ImageButton imgBtn = new ImageButton(); imgBtn.ID = "itemBtn"; imgBtn.Width = Unit.Pixel(30); imgBtn.ImageUrl = "~/Images/Game/Items/" + myItem.ItemImageUrl; ContextMenu menu = new ContextMenu(); menu.BoundControls.Add(imgBtn); menu.ItemCommand += new CommandEventHandler(menu_ItemCommand); menu.AutoHide = true; menu.RolloverColor = Color.Gray; menu.ID = "MenuMenu"; Panel panel = (Panel)(e.Item.FindControl("ItemPanel")); panel.Controls.Add(imgBtn); panel.Controls.Add(menu); AsyncPostBackTrigger trig = new AsyncPostBackTrigger(); trig.ControlID = menu.UniqueID; trig.EventName = "ItemCommand"; ItemsUpdatePanel.Triggers.Add(trig); </code></pre> <p>So, I actually add an AsyncPostBackTrigger to the menu, so the ItemCommand event should be registered. What happends when I click an item in this contextmenu, is a full postback happends.</p> <p>I have been trying to play with the ChildrenAsTriggers property without help. I have also been moving the AsyncPostBackTrigger code up and down, also without help.</p> <p>Thanks a lot beforehand..! Lars</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload