Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在asp.net中使用html表动态添加按钮_C#_Asp.net - Fatal编程技术网

C# 如何在asp.net中使用html表动态添加按钮

C# 如何在asp.net中使用html表动态添加按钮,c#,asp.net,C#,Asp.net,我想在html表中动态添加按钮 我创建了一个母版页和另一个子页 在子页面上,我想在html表中动态添加一个按钮 这是我的代码: Button btnSend = new Button(); btnSend.ID = "btnSend"; btnSend.Text = "Send"; btnSend.Click += new System.EventHandler(btnSend_Click); this.form1.Controls.Add(btnSend); 但我有一个错误: 无法从子页访问

我想在html表中动态添加按钮

我创建了一个母版页和另一个子页

在子页面上,我想在html表中动态添加一个按钮

这是我的代码:

Button btnSend = new Button();
btnSend.ID = "btnSend";
btnSend.Text = "Send";
btnSend.Click += new System.EventHandler(btnSend_Click);
this.form1.Controls.Add(btnSend);
但我有一个错误:

无法从子页访问form1


请帮助我在html表中动态添加按钮。

如果使用asp.net,则没有表单。因此,只需从工具箱中插入一个按钮,并根据需要设置
buttonName.visible=true
false

是否在codebehind上创建HTML表?如果是这样,您可以在那里添加按钮。
如果没有,您可以尝试在那里输入文字,如果需要,用HTML按钮的代码填充。

如果您想在子页面中添加动态控件,那么我建议您添加一个面板,然后只需使用panel.controls.add(您的按钮)即可。

如果有帮助,请将我的答案标记为您的解决方案(将答案标记为已接受,单击答案旁边的复选标记将其从灰色切换为已填写)。谢谢