在 table header 单元格内动态添加一个 em 标签 Asp.net
Add a em tag inside table header cell dynamically in Asp.net
我的代码中有一个 table。 table headers 是动态决定的
heder 用于文本框列。
var thc = new TableHeaderCell { Text = "Iteration", CssClass = "iteration" }
我必须更改标签显示方式的逻辑,以指示文本框条目是否为必填项。
<em id="lblIterationMandatory" runat="server" class="mandatoryIndicator"
style="display: none;">*</em>
如果 css 定义为必填指示符 class 的文本框值是必填的,我想在标题单元格中添加一个 * 星号。
我的输出应该是 Iteration(black) *(red color,bold).
var thc= new TableHeaderCell { Text = @"Iteration <em id='Iteration' runat='server' class='mandatoryIndicator' style='display: none;'>*</em>", CssClass = "iteration" };
我试过这种方法。但是*不会显示。
由于 Iteration 和 * 都是不同的颜色,我想我必须对 *.
使用单独的控件
用户 InnerHtml
而不是 Text
var thc= new TableHeaderCell { InnerHtml= @"Iteration <em id='Iteration' runat='server' class='mandatoryIndicator' style='display: none;'>*</em>", CssClass = "iteration" };
同时使用 style='display: none;'
将在编写它的浏览器上隐藏任何内容。
您将 em 的显示设置为 none
将其更改为 block
var thc= new TableHeaderCell { Text = @"Iteration <em id='Iteration' runat='server' class='mandatoryIndicator' style='display: block;'>*</em>", CssClass = "iteration" };
我的代码中有一个 table。 table headers 是动态决定的 heder 用于文本框列。
var thc = new TableHeaderCell { Text = "Iteration", CssClass = "iteration" }
我必须更改标签显示方式的逻辑,以指示文本框条目是否为必填项。
<em id="lblIterationMandatory" runat="server" class="mandatoryIndicator"
style="display: none;">*</em>
如果 css 定义为必填指示符 class 的文本框值是必填的,我想在标题单元格中添加一个 * 星号。 我的输出应该是 Iteration(black) *(red color,bold).
var thc= new TableHeaderCell { Text = @"Iteration <em id='Iteration' runat='server' class='mandatoryIndicator' style='display: none;'>*</em>", CssClass = "iteration" };
我试过这种方法。但是*不会显示。 由于 Iteration 和 * 都是不同的颜色,我想我必须对 *.
使用单独的控件用户 InnerHtml
而不是 Text
var thc= new TableHeaderCell { InnerHtml= @"Iteration <em id='Iteration' runat='server' class='mandatoryIndicator' style='display: none;'>*</em>", CssClass = "iteration" };
同时使用 style='display: none;'
将在编写它的浏览器上隐藏任何内容。
您将 em 的显示设置为 none
将其更改为 block
var thc= new TableHeaderCell { Text = @"Iteration <em id='Iteration' runat='server' class='mandatoryIndicator' style='display: block;'>*</em>", CssClass = "iteration" };