在 VB 代码中,在我创建 Div 以在 if 语句期间将文本更改为红色之前,文本在复选框旁边对齐。现在,当我添加颜色更改代码时,child.Text = "<div style='color:Red; display: inline; float: left;'>" + child.Text & "</div>"
,它将文本移动到复选框下方而不是复选框旁边。我试过 Span 但它不起作用。我希望文本位于复选框旁边。
这里是详细的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>
最佳答案
我找到了解决方案,而不是使用 <div>
, 我用 <font>
.这样,它会删除空格并移回下一个复选框行。
child.Text = "<font color='red'>" + child.Text + "</font>"
关于asp.net - 为什么文本在复选框下方移动而不是在复选框旁边移动 1 行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19775400/