开发者

dynamically add link buttons in asp.net

I have a problem that I am creating linkbuttons dynamically in a panel in asp.net but I can not place it new lines, it only appears together. Please help me out.

My Code is:

        LinkButton lb = new LinkButton();
        lb.Text = TextBox1.Text;
        lb.ID = TextBox2.Text;
        Panel1.Controls.Add(lb);

   开发者_Python百科     Panel1.Controls.Add(new LiteralControl("
        "));


You would need to surround the LinkButton in a block-level HTML element such as <div> or <p>, or insert a LiteralControl with a line break tag <br/> before you add the LinkButton

Panel1.Controls.Add(new LiteralControl("<br/>"));
LinkButton lb = new LinkButton();
lb.Text = TextBox1.Text;
lb.ID = TextBox2.Text;
Panel1.Controls.Add(lb);

Or...

Panel1.Controls.Add(new LiteralControl("<div>"));
LinkButton lb = new LinkButton();
lb.Text = TextBox1.Text;
lb.ID = TextBox2.Text;
Panel1.Controls.Add(lb);
Panel1.Controls.Add(new LiteralControl("</div>"));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜