【发布时间】:2012-05-08 13:54:02
【问题描述】:
这是与my last question 相关的问题,以防您需要更多背景信息。
我的问题是:是否可以让 asp.net 表格中的单元格可点击?
或者是否至少可以在 ASP.NET 中制作一个可点击的 WebControl(应该可以放置在 ControlCollection 中),而不是 Button 或 LinkButton? 如果没有,是否可以将多行信息放入按钮文本中?
我尝试将其他组件添加到按钮的 ControlCollection(我已经看到在 Button 的 Windows 窗体版本中工作),以查看是否可以将子组件呈现到按钮,但没有成功:
private void ModifyTableCell(TableCell cell)
{
//Create new button
Button btnCell = new Button();
btnCell.Click += (sender, args) =>
{
//Event for the button
};
//Create new Label
Label lblCell = new Label();
lblCell.Font.Bold = true;
lblCell.Text = "This text won't appear";
btnCell.Controls.Add(lblCell); //Attempt to add label to Button
cell.Controls.Add(btnCell);
}
编辑:我最终只是为整个单元格创建了一个多行链接按钮。
【问题讨论】:
标签: c# asp.net button web-controls