Sry,我错过了这个基本的东西。没有线索如何实现这一点。在asp.net中动态添加控件之间的换行ajax updatepanel
这里是我的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>
这是我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;
for (int i = 0; i < count; i++)
{
TextBox t = new TextBox();
t.Text = "hello"+i.ToString();
MainPlaceHolder.Controls.AddAt(MainPlaceHolder.Controls.Count, t);
}
}
当我运行这个程序,当我点击按钮,添加一个新的文本框控件每次。没关系。但是我希望在每个文本框控件之间有一个突破的空间!请帮我解决我错过的那篇文章。
我试着用一个br标签在asp占位符的结束标签上方。它失败了。如果我想要在每个动态添加的文本框旁边添加两个按钮,我是否在正确的路径上扩展问题?为了一个大问题,无法将其最小化。
那是怎么了? ag“失败”?它没有被渲染?它是否被渲染,但没有达到你想要的换行符? – 2013-02-08 17:37:38