public class BlogComment
{
    public int ID;
    public int UserID;
    public string Username;
    public string Comment;
    public DateTime Date;
    public int VotesUp;
    public int VotesDown;
    public Panel GetCommentPanel()
    {
        Panel WrapPanel = new Panel();
        WrapPanel.CssClass = "user-comment-wrapper";
        Panel VotePanel = new Panel();
        VotePanel.CssClass = "rfloat";
        HyperLink UpVote = new HyperLink();
        HyperLink DownVote = new HyperLink();
        UpVote.CssClass = "s vote-box vote-up";
        DownVote.CssClass = "s vote-box vote-down";
        UpVote.NavigateUrl="#";
        DownVote.NavigateUrl = "#";
        VotePanel.Controls.Add(UpVote);
        VotePanel.Controls.Add(DownVote);
        WrapPanel.Controls.Add(VotePanel);
        Panel UserTextPanel = new Panel();
        UserTextPanel.CssClass = "user-comment-txt";
        Literal UserText = new Literal();
        UserText.Text = this.Comment;
        UserTextPanel.Controls.Add(UserText);
        return WrapPanel;
    }
Trying to generate the following HTML:
<div class="user-comment-wrapper">
    <div style="float:right">
        <a class="s vote-box vote-up" href="#"></a>
        <a class="s vote-box vote-down" href="#"></a>
    </div>  
    <div class="user-comment-txt">
        Object comes with instantiated Department with empty atributes Object comes with instantiated Department with empty atributes Object comes with in开发者_如何学Gostantiated Department with empty atributes.Department with empty atributes Object comes with instantiated Department with empty atributes Object comes with instantiated Department with empty atributes.    
    </div>
    <div class="comment-info-wrapper">
        <div style="float:left">
            <strong>Posted by <a href="#">Tom</a></strong>
        </div>
        <div style="float:right">
            <strong><abbr class="timeago" title="2008-07-17T09:24:17Z">July 17, 2008</abbr></strong>
        </div>
        <div class="clear"></div>
    </div>            
</div>
I mean it works, but I can't help but feel this design sucks.
Just write the plain old-good HTML in your ASPX page.
<div class="user-comment-wrapper">
    <div class="voting">
        <a class="s vote-box vote-up" href="#"></a>
        <a class="s vote-box vote-down" href="#"></a>
    </div>  
    <div class="user-comment-txt">
        <%: GetCommentContent() %>
    </div>
    <div class="comment-info-wrapper">
        <div class="author-info">
            <strong>Posted by 
              <a href="#"> <%: GetCommentAuthor() %></a>
            </strong>
        </div>
        <div class="comment-info">
            <strong>
              <abbr class="timeago" title="<%: GetShortCommentTime() %>">
                <%: GetFriendlyCommentTime() %>
              </abbr>
            </strong>
        </div>
        <div class="clear"></div>
    </div>            
</div>
Please not the additional classes applied. Then you can add CSS:
.user-comment-wrapper .voting { float: right; }
.comment-info-wrapper .author-info { float: left; }
.comment-info-wrapper .comment-info { float: right; }
Also you are injecting content using ASP.NET 4 <%:..%> (or it can be a usual <%=...%>, but make sure you HTML escape it).
I don't see any reason to manually create those absolutely unreadable server-side controls in order to render HTML.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论