Thursday, 15 September 2011

c# - Creating an asyncpostback from a control inside a repeater -



c# - Creating an asyncpostback from a control inside a repeater -

i have repeater itemtemplate contains placeholder add together input controls (listbox, textbox, calendarextender etc.) on itemdatabound:

<asp:updatepanel id="reportparameterupdatepanel" updatemode="conditional" runat="server"> <contenttemplate> <asp:repeater id="reportparametereditrepeater" onitemdatabound="reportparametereditrepeater_itemdatabound" runat="server"> <itemtemplate> <asp:placeholder runat="server" id="parameterentryplaceholder"></asp:placeholder> </itemtemplate> </asp:repeater> </contenttemplate> </asp:updatepanel>

how can generate asyncpostback 1 of these textboxes within repeater (on textchanged)?

the command created dynamically , want create postback under conditions, needs done code behind.

i have tried:

onitemcommand (but appears buttons) scriptmanager.registerasyncpostbackcontrol (doesn't seem on textchanged) updatepanel.triggers.add(new asyncpostbacktrigger ...) (unable find textbox within repeater)

in reportparametereditrepeater_itemdatabound need assign unique id each control, , bind text changed event. store in session. add together placeholder. below how did in site button click event:

templatecontrols_headline ctrl = (templatecontrols_headline)loadcontrol("~/controls/templateheadline.ascx"); ctrl.id = "myctrl_" + cmssession.current.addedtemplatecontrols.count; ctrl.remove.click += new eventhandler(removeitem_onclick); mysession.current.addedtemplatecontrols.add((control)ctrl); placeholder ph = accaddtemplates.findcontrol("phaddtemplatecontrolsarea") placeholder; ph.controls.add(ctrl);

then, in oninit of page, have re-bind viewstate since creating them dynamically, unique id created comes in (this postbacks):

protected override void oninit(eventargs e) { placeholder ph = accaddtemplates.findcontrol("phaddtemplatecontrolsarea") placeholder; int counter = 0; foreach (usercontrol ctrl in mysession.current.addedtemplatecontrols) { ctrl.id = "myctrl_" + counter; ctrl.remove.commandargument = counter.tostring(); ctrl.remove.click += new eventhandler(removeitem_onclick); counter++; ph.controls.add(ctrl); } base.oninit(e); }

c# asp.net updatepanel postback repeater

No comments:

Post a Comment