c# - Updatepanel gives full postback instead of asyncpostback -
i have run seems famous problem: updatepanel fires full postback instead of async postback. normal solution give controls add dynamically id, have done, still full postback instead of async postback...
here's code:
html:
<asp:updatepanel id="itemsupdatepanel" runat="server" updatemode="conditional" childrenastriggers="false"> <triggers> </triggers> <contenttemplate> <asp:listview id="playeritems" runat="server" groupitemcount="5" onitemdatabound="playeritems_itemdatabound"> <layouttemplate> ... listview stuff ... </asp:listview> </contenttemplate> </asp:updatepanel>
the interesting part c# code behind (method playeritems_itemdatabound), following:
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);
so, add asyncpostbacktrigger menu, itemcommand event should registered. happends when click item in contextmenu, full postback happends.
i have been trying play childrenastriggers property without help. have been moving asyncpostbacktrigger code , down, without help.
thanks lot beforehand..! lars
from asyncpostbacktrigger documentation:
programmatically adding asyncpostbacktrigger controls not supported. programmatically register postback control, use registerasyncpostbackcontrol method of scriptmanager control. call update method of updatepanel control when control posts back.
Comments
Post a Comment