如何在按钮的每次单击事件上添加多个单选按钮 [英] How to add multiple radio buttons on every click event of a button
问题描述
我正在创建其中具有InsertQuestion.aspx页面的在线考试项目(Asp.Net).
我有1个textBox和1个Button ant面板Control.
在点击按钮时,我要动态添加单选按钮&在按钮的每次单击事件上将Radiobutton的文本设置为textBox的文本
并添加到面板控件
请告诉我解决方案.
我尝试过的事情:
AddButton_Click()
{
RadioButton rb =新的RadioButton();
rb.Text = Textbox1.Text;
Panel1.controls.add(rb);
}
I am Creating Online Exam Project(Asp.Net) in which i have InsertQuestion.aspx Page.
I have 1 textBox and 1 Button ant panel Control.
On Click Of a Button i want to add a Radiobutton dynamically & set the text of Radiobutton as text Of textBox on Every Click Event of a button
And add to a panel control
please tell me Solution.
What I have tried:
AddButton_Click()
{
RadioButton rb = new RadioButton();
rb.Text = Textbox1.Text;
Panel1.controls.add(rb);
}
推荐答案
维护动态控件并不是一个微不足道的过程,因为您必须在每个回发中重新添加所有动态控件,.net可以.为您管理它们.
动态创建控件| ASP.NET论坛 [^ ]
Maintaining dynamic controls is not a trivial process as you have to re-add all of your dynamic controls on every postback, .net can''t manage them for you.
Dynamically creating controls | The ASP.NET Forums[^]
这篇关于如何在按钮的每次单击事件上添加多个单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!