Friday, 15 July 2011

c# - Access dynamically created text box in a custom template for an ajax tab -



c# - Access dynamically created text box in a custom template for an ajax tab -

i have tabcontainer in aspx page follows

<asp:tabcontainer id="tabcontainer" runat="server" activetabindex="0"> </asp:tabcontainer>

am creating tabs above containter using c# code on oninit event of page

protected override void oninit(eventargs e) { lstcategories = service.getcategories(); numberofcategories = lstcategories.count; createtabs(); base.oninit(e); } protected void createtabs() { seek { (int = 0; < numberofcategories; i++) { tabpanel asptab = new tabpanel(); asptab.id = lstcategories[i].id.tostring(); asptab.headertext = lstcategories[i].name; mycustomtemplate obj = new mycustomtemplate(lstcategories[i].id); asptab.contenttemplate = obj; tabcontainer.tabs.add(asptab); } } grab (exception ex) { } } public class mycustomtemplate : itemplate { public table tbl; public textbox tbxquantity; public image img; public int countofitemsperrow = 2; public mycustomtemplate(int paramcategoryid) { categoryid = paramcategoryid; } public void instantiatein(control container) { initialisetheproperties(); container.controls.add(tblhardware); } public table initialisetheproperties() { //intialize mater table tbl = new table(); //create row mater table tablerow row = new tablerow(); tablecell cell = new tablecell(); img = new image(); img.imageurl = httpruntime.appdomainappvirtualpath +"/images/"+"1.jpg"; cell.controls.add(img); tblhardware.rows.cells.add(cell); tbxquantity = new textbox(); tbxquantity.id ="tbxquantity"; cell.controls.add(tbxquantity); tblhardware.rows.cells.add(cell); tblhardware.rows.add(row); //return tbl; } } }

now trying on btnclickevent

public void btnsave_click(object sender, eventargs e) { seek { command cntrl = page.findcontrol("tbxquantity"); } grab (exception ex) { } }

it returns null. doing wrong? kindly help

as found reply above question posted myself, help fellow folks encounter same or similar problem.

string strquantity=((system.web.ui.webcontrols.textbox)(((ajaxcontroltoolkit.tabcontainer)(btn.parent.findcontrol("tabcontainer"))).tabs[0].findcontrol("tbxquantity"))).text

thank "stackoverflow" maintaining site , give thanks members help developers me.

c# asp.net

No comments:

Post a Comment