asp.net - 为什么文本在复选框下方移动而不是在复选框旁边移动 1 行?

标签 asp.net css vb.net

在 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/

相关文章:

asp.net - 使用 SPAN 文本而不是输入或选择控件的表单样式

c# - 确定 Kubernetes 中应用程序关闭的原因

javascript - 向 Dropzone.js 中的每个文件添加表单字段

html - devtools 中的 CSS webkit-sticky 属性无效

javascript - 更改颜色 collapsibleset Jquery Mobile

html - 为什么我的调试消息没有写入我的页面?

c# - 一次构建多个解决方案平台?

vb.net - 如何确定一个整数由多少个部分组成

javascript - 如何防止模式弹出asp.net

html - Wordpress 仅在窄屏幕上读取某些样式