我如何添加一个小组的换行符或HTML里面? [英] How can I add a line break or html inside of a Panel?

查看:178
本文介绍了我如何添加一个小组的换行符或HTML里面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建具有以下code的菜单。但我无法弄清楚如何让每一个LinkBut​​ton的出现在单独的行。

  MenuPanel.Controls.Clear();
的foreach(在形式FORMLIST F)
{
  如果(f.IsActive ==y)的
  {
     FormUserControl FC =(FormUserControl)LoadControl(f.StartControl);
     LinkBut​​ton的磅=新的LinkBut​​ton();
     lb.Text = fc.Title;
     MenuPanel.Controls.Add(磅);
     //我想某种换行符这里
  }
}
 

解决方案

使用的<一个href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.literal.aspx"><$c$c>LiteralControl类插入一个换行符...

  MenuPanel.Controls.Add(新LiteralControl(&LT; BR /&gt;中));
 

或者使用CSS,使你的链接块级元素...

  #menu一个{显示:块; }
 

I am trying to create a menu with the following code. But I cannot figure out how to get each LinkButton to appear on seperate lines.

MenuPanel.Controls.Clear();
foreach (FormList f in forms)
{
  if (f.IsActive == "y")
  {
     FormUserControl fc = (FormUserControl)LoadControl(f.StartControl);
     LinkButton lb = new LinkButton();
     lb.Text = fc.Title;
     MenuPanel.Controls.Add(lb);
     // I want some sort of line break here
  }
}

解决方案

Use the LiteralControl class to insert a line break...

MenuPanel.Controls.Add(new LiteralControl("<br />")); 

Or use CSS to make your links block-level elements...

#menu a { display: block; }

这篇关于我如何添加一个小组的换行符或HTML里面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆