HtmlGenericControl(“br”) rendering twice

前端 未结 2 1578
长情又很酷
长情又很酷 2020-12-20 17:08

I\'m adding some content to a given web page from code behind. When I want to add a break after some text, I try to do that this way:

pDoc.Controls.Add(New L         


        
2条回答
  •  伪装坚强ぢ
    2020-12-20 17:49

    Actually you can use;

    pDoc.Controls.Add(new LiteralControl("
    "));

    Whereas new HtmlGenericControl("br") adds two
    , this will only add
    tag to your HTML so that you just have 1 space line. In this picture I added those breaks with that code block.

    enter image description here

    Also similar question here: Server control behaving oddly

提交回复
热议问题