我有这个方法:
while (created < 2)
{
var tb = new TagBuilder("input");
tb.MergeAttribute("id", model.QuestionId);
tb.MergeAttribute("name", model.QuestionId);
tb.MergeAttribute("type", "radio");
if (model.Disabled == true)
{
tb.MergeAttribute("Disabled", model.Disabled.ToString());
}
tb.MergeAttributes(GetHtmlAttributes(model.HtmlAttributes));
tb.AddCssClass("form-field");
var innerText = created % 2 == 0 ? "Kvinna" : "Man";
tb.MergeAttribute("value", innerText);
sb.Append(tb.ToString(TagRenderMode.SelfClosing));
var spanBuilder = new TagBuilder("span");
spanBuilder.SetInnerText(innerText);
This code ---> var spanBuilders = new TagBuilder("span");
spanBuilders.MergeAttribute("id", model.QuestionId + "radio");
spanBuilders.MergeAttribute(spanBuilder.ToString((TagRenderMode.Normal)));<---
sb.Append(spanBuilder.ToString(TagRenderMode.Normal));
}
我想要做的是以某种方式合并 span-tag spanbuilder 并将其放入另一个标签中。while-loop 会通过两次,因此它将创建 spanbuilder 的两个跨度标签,我希望它们的展位位于另一个跨度标签内。有没有好的方法来做到这一点?