net c#。我正在使用占位符,并动态添加跨度到占位符。如何在c#asp.net中动态添加文本?
答案 0 :(得分:4)
你可以使用html泛型控件,就像这样
var yourspan = new HtmlGenericControl("span");
span.InnerHtml = "the text inside your span ";
yourspan.Attributes["id"] = "yourspan";
pannel.Controls.Add(span);
http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlgenericcontrol.aspx
答案 1 :(得分:2)
Make table runat =“server”
<table id="myTable" runat="server" width="100%">
<tr>
<td>
<span></span>
</td>
</tr>
</table>
**In code behind u do like this**
myTable.Rows[1].Cells[0].InnerHtml = "<span id="1">" + YOURTEXT+ "</span>";