在 VB 代码中,在我创建 Div 以在 if 语句期间将文本更改为红色之前,文本与复选框对齐。现在,当我添加颜色更改代码时child.Text = "<div style='color:Red; display: inline; float: left;'>" + child.Text & "</div>"
,它会将文本移动到复选框下方而不是复选框旁边。我尝试了跨度,但它不起作用。我希望文本位于复选框旁边。
这是详细的VB代码,
'populate the child nodes
While dr.Read()
Dim child As TreeNode = New TreeNode(dr("Name"), dr("Name"))
Dim complianceFlag As Boolean
If Boolean.TryParse(dr("Compliance"), complianceFlag) Then
' Yes, compliance value is a Boolean, now set color based on value
If Not complianceFlag Then
child.Text = "<div style='color:Red; display: inline; float: left;'>" + child.Text & "</div>"
End If
Else
End If
rootNode.ChildNodes.Add(child)
child.SelectAction = TreeNodeSelectAction.None
End While
HTML代码,
<div>
<asp:UpdatePanel ID="UpdatePanel6" runat="server">
<ContentTemplate>
<asp:TreeView onclick="client_OnTreeNodeChecked();" ID="TreeViewGroups" runat="server"
ShowCheckBoxes="All" ExpandDepth="0" CssClass="bold">
</asp:TreeView>
<asp:Label ID="LabelNoServers" runat="server" Text=""></asp:Label>
</ContentTemplate>
<Triggers>
<%--<asp:AsyncPostBackTrigger ControlID="b_DelYes" EventName="Click" />--%>
</Triggers>
</asp:UpdatePanel>
</div>