我在我的网页上动态地列出了一些控件,或者我在Label中添加了新行。在控件之间动态地添加<br/> asp.net
Label newLine = new Label();newLine.Text = "<br/>"; myPanel.Controls.Add(newLine);
我该如何以不同的方式做到这一点?
我在我的网页上动态地列出了一些控件,或者我在Label中添加了新行。在控件之间动态地添加<br/> asp.net
Label newLine = new Label();newLine.Text = "<br/>"; myPanel.Controls.Add(newLine);
我该如何以不同的方式做到这一点?
myPanel.Controls.Add(new LiteralControl("<br />"));
我建议你根本不要使用
。使用CSS来显示你的控件。显示:您的元素块将工作得很好。不那么凌乱!
我使用Css,但我不知道我可以用Css做到这一点。你能写出如何?我应该使用哪个css代码? – softwaremonster 2010-06-23 14:25:53
我的问题: 将文本添加到面板,指示日期范围。文本应放置在超链接下。
CSS的解决方案:
A.创建CSS类(将其放置在您的网页或到CSS文件)
.dateRange
{
display:block;
}
B.创建控件和组适当的CSS类(.CssClass属性)
//1. Create the link
LinkButton _btnTitle = new LinkButton();
_btnTitle.Text = Request.QueryString["name"];
_btnTitle.OnClientClick = "history.go(-1); return false;";
_btnTitle.ToolTip = Request.QueryString["name"];
_btnTitle.CssClass = "title";
//2. Add the link to the container
pnlFindTech.Controls.Add(_btnTitle);
//3. Create the label (text)
Label lblDate = new Label();
lblDate.Text = " [ From " + txtDateFrom.Text + " To " + txtDateTo.Text + " ] ";
lblDate.CssClass = "dateRange"; //Here is the trick
//4. Add the label to the container
pnlFindTech.Controls.Add(lblDate);
最终输出看起来像这样:
来源:
因为我是新手,在这里我必须等待特殊时间来标记答案是正确的。 – softwaremonster 2010-06-22 17:05:50