TreeNode RenderPostText样式

| 我正在扩展TreeNode并覆盖RenderPostText,我想在节点的末尾添加标签。 标签应移至右侧,并一字直下对齐。 我现在所拥有的:(不是我想要的,标签未对齐)
protected override void RenderPostText(HtmlTextWriter writer)
{
   writer.AddStyleAttribute(HtmlTextWriterStyle.MarginLeft, \"250px\");
   writer.RenderBeginTag(HtmlTextWriterTag.Span);
   writer.Write(\"LABEL\");
   writer.RenderEndTag();
   base.RenderPostText(writer);
}
浏览器生成以下代码:
<div id=\"CustomTreeView1\">
    <table cellspacing=\"0\" cellpadding=\"0\" style=\"border-width:0;\">
        <tbody><tr>
            <td><a href=\"javascript:TreeView_ToggleNode(CustomTreeView1_Data,0,document.getElementById(\'CustomTreeView1n0\'),\' \',document.getElementById(\'CustomTreeView1n0Nodes\'))\" id=\"CustomTreeView1n0\"><img style=\"border-width:0;\" alt=\"Collapse Node1\" src=\"/WebResource.axd?d=0LdB1b1_hIJIUCl6sgbTDwZP1PqSlJ3nEAs9RyFhhbFOrEZWA69PFGUD8UnFd3CmlnXXDykXOkYb6vloumJmNTV3T2cN1sRb8dj_XP3B36tSwYv59yT2TFUDF1XMP3tC0&amp;t=634307713248437500\"></a></td><td style=\"white-space:nowrap;\"><input type=\"checkbox\" id=\"CustomTreeView1n0CheckBox\" name=\"CustomTreeView1n0CheckBox\"><a id=\"CustomTreeView1t0\" onclick=\"TreeView_SelectNode(CustomTreeView1_Data, this,\'CustomTreeView1t0\');\" href=\"javascript:__doPostBack(\'CustomTreeView1\',\'sNode1\')\" class=\"CustomTreeView1_0\">Node1</a><span style=\"margin-left:250px;\">LABEL</span></td>
        </tr>
    </tbody></table><div style=\"display:block;\" id=\"CustomTreeView1n0Nodes\">
        <table cellspacing=\"0\" cellpadding=\"0\" style=\"border-width:0;\">
            <tbody><tr>
                <td><div style=\"width:20px;height:1px\"></div></td><td><a href=\"javascript:TreeView_ToggleNode(CustomTreeView1_Data,1,document.getElementById(\'CustomTreeView1n1\'),\' \',document.getElementById(\'CustomTreeView1n1Nodes\'))\" id=\"CustomTreeView1n1\"><img style=\"border-width:0;\" alt=\"Collapse Node2\" src=\"/WebResource.axd?d=0LdB1b1_hIJIUCl6sgbTDwZP1PqSlJ3nEAs9RyFhhbFOrEZWA69PFGUD8UnFd3CmlnXXDykXOkYb6vloumJmNTV3T2cN1sRb8dj_XP3B36tSwYv59yT2TFUDF1XMP3tC0&amp;t=634307713248437500\"></a></td><td style=\"white-space:nowrap;\"><input type=\"checkbox\" id=\"CustomTreeView1n1CheckBox\" name=\"CustomTreeView1n1CheckBox\"><a id=\"CustomTreeView1t1\" onclick=\"TreeView_SelectNode(CustomTreeView1_Data, this,\'CustomTreeView1t1\');\" href=\"javascript:__doPostBack(\'CustomTreeView1\',\'sNode1\\\\Node2\')\" class=\"CustomTreeView1_0\">Node2</a><span style=\"margin-left:250px;\">LABEL</span></td>
            </tr>
        </tbody></table><div style=\"display:block;\" id=\"CustomTreeView1n1Nodes\">
            <table cellspacing=\"0\" cellpadding=\"0\" style=\"border-width:0;\">
                <tbody><tr>
                    <td><div style=\"width:20px;height:1px\"></div></td><td><div style=\"width:20px;height:1px\"></div></td><td><img alt=\"\" src=\"/WebResource.axd?d=aAOD5g58ic2Dyy2j7ixwQreE7Dpb8bpKl_xmoKpMHe9oWkQKGRM7ihb90wYKM9JeccXzs42e-0b6vjGRgr4SVqUWclDUDk-H6Nircokjs_I3zT2h2LljOQCZRPfv3Vok0&amp;t=634307713248437500\"></td><td style=\"white-space:nowrap;\"><input type=\"checkbox\" id=\"CustomTreeView1n2CheckBox\" name=\"CustomTreeView1n2CheckBox\"><a id=\"CustomTreeView1t2\" onclick=\"TreeView_SelectNode(CustomTreeView1_Data, this,\'CustomTreeView1t2\');\" href=\"javascript:__doPostBack(\'CustomTreeView1\',\'sNode1\\\\Node2\\\\Node4\')\" class=\"CustomTreeView1_0\">Node4</a><span style=\"margin-left:250px;\">LABEL</span></td>
                </tr>
            </tbody></table>
        </div><table cellspacing=\"0\" cellpadding=\"0\" style=\"border-width:0;\">
            <tbody><tr>
                <td><div style=\"width:20px;height:1px\"></div></td><td><img alt=\"\" src=\"/WebResource.axd?d=aAOD5g58ic2Dyy2j7ixwQreE7Dpb8bpKl_xmoKpMHe9oWkQKGRM7ihb90wYKM9JeccXzs42e-0b6vjGRgr4SVqUWclDUDk-H6Nircokjs_I3zT2h2LljOQCZRPfv3Vok0&amp;t=634307713248437500\"></td><td style=\"white-space:nowrap;\"><input type=\"checkbox\" id=\"CustomTreeView1n3CheckBox\" name=\"CustomTreeView1n3CheckBox\"><a id=\"CustomTreeView1t3\" onclick=\"TreeView_SelectNode(CustomTreeView1_Data, this,\'CustomTreeView1t3\');\" href=\"javascript:__doPostBack(\'CustomTreeView1\',\'sNode1\\\\Node3\')\" class=\"CustomTreeView1_0\">Node3</a><span style=\"margin-left:250px;\">LABEL</span></td>
            </tr>
        </tbody></table>
    </div>
</div>
    
已邀请:

要回复问题请先登录注册