Sunday, 15 February 2015

Line breaks between dynamically added controls in asp.net ajax updatepanel -



Line breaks between dynamically added controls in asp.net ajax updatepanel -

sry, missing basic thing. no clue on how accomplish this.

here default.aspx

<asp:content id="bodycontent" runat="server" contentplaceholderid="maincontent"> <asp:scriptmanager id="mainscriptmanager" runat="server" /> <asp:updatepanel enableviewstate="true" updatemode="always" id="mainpanel" runat="server"> <contenttemplate> <asp:placeholder id="mainplaceholder" runat="server"> <%--<asp:button runat="server" id="editbutton" onclick="updatebutton_click" text="edit" visible="true"/> <asp:button runat="server" id="deletebutton" onclick="updatebutton_click" text="delete" visible="true"/> --%> <%--<br />--%> </asp:placeholder> </contenttemplate> </asp:updatepanel> <asp:button runat="server" id="updatebutton2" onclick="updatebutton_click" text="add" /> </asp:content>

here default.aspx.cs

protected void page_load(object sender, eventargs e) { if (!ispostback) { } } protected void updatebutton_click(object sender, eventargs e) { int count = 0; if (viewstate["buttoncount"] != null) { count = (int)viewstate["buttoncount"]; } count++; viewstate["buttoncount"] = count; (int = 0; < count; i++) { textbox t = new textbox(); t.text = "hello"+i.tostring(); mainplaceholder.controls.addat(mainplaceholder.controls.count, t); } }

when run app , when click button, new text box command added every time. thats fine. want have breaking space between each text box control! pls help me piece missing.

i tried br tag above closing tag of asp place holder. failed. extending question, on right path if want add together 2 buttons beside every dynamically added text box? sry big question. couldnt minimise more.

i expect modifying code work:

for (int = 0; < count; i++) { textbox t = new textbox(); t.text = "hello"+i.tostring(); mainplaceholder.controls.addat(mainplaceholder.controls.count, t); literal lit = new literal() { mode=literalmode.passthrough, text="<br/>" }; mainplaceholder.controls.addat(mainplaceholder.controls.count, lit); }

asp.net ajax asp.net-ajax updatepanel

No comments:

Post a Comment