当然不行。据个简单的例子:TableCell tableCell = 你的控件.Cells[0];
private Button button = new Button();
button .ID="它的ID"
tableCell.Contorl.add(button)
这样才能作为服务器端的控件用,多参考一下资料,以前有个分页的DataGrid是个很好的例子
private Button button = new Button();
button .ID="它的ID"
tableCell.Contorl.add(button)
这样才能作为服务器端的控件用,多参考一下资料,以前有个分页的DataGrid是个很好的例子
解决方案 »
- ext.net 按钮的Icon 的图标为什么显示不全啊 ?只显示一小部分
- 怎么动态添加TABLE的行数?
- GridView or DataGrid列头设置问题
- 请教一个Calendar的问题
- 编辑器和微软的Treeview控件一起使用的难解问题!!!
- 新申请的.NET的QQ群,欢迎大家加入:6650191
- 请问如何在远程服务器上启动调试?
- 高手指点asp.net如何实现再线编辑文章的功能
- 请教动态加服务器端table控件的tablecell的时候,如果tablecell.text = “”,怎么让该tablecell的BorderWidth属性显示出来??
- 请教大侠:在那可以下载微软TreeView控件...
- 如何实现通过 url 加密 ?
- 怎样得到一个表的所有的字段名称????????
然后
容器.Controls.Add(button)
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;namespace WebControlLibrary1
{ public class WebCustomControl1 : System.Web.UI.WebControls.WebControl
{
private Button button = new Button(); protected override void CreateChildControls()
{
button.Text="MyButton";
button.ID = "button";
Controls.Add(button);
} }
}
orusing System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;namespace WebControlLibrary1
{ public class WebCustomControl1 : System.Web.UI.WebControls.WebControl
{
private Button button = new Button(); protected override void Render(HtmlTextWriter output)
{
//not easy to handle events
button.Text="MyButton";
button.ID = "button";
button.RenderControl(output);
}
}
}