English 中文(简体)
有活力的布顿电台 变换活动赢得了大火
原标题:Dynamic Radio Button CheckedChanged event won t fire

我正在与C#动态地创建两个无线电塔州,但检查后Change事件是发射的。 我使用以下法典:

RadioButton enable = new RadioButton();
enable.ID = "enable";
enable.Text = "Enable";
enable.GroupName = "enableDisableGroup";
enable.CheckedChanged += new EventHandler(enableRadioButton_CheckedChanged);

RadioButton disable = new RadioButton();
disable.ID = "disable";
disable.Text = "Disable";
disable.GroupName = "enableDisableGroup";
disable.CheckedChanged += new EventHandler(disableRadioButton_CheckedChanged);

UpdatePanel upEnableDisable = new UpdatePanel();
upEnableDisable.UpdateMode = UpdatePanelUpdateMode.Conditional;
upEnableDisable.ContentTemplateContainer.Controls.Add(enable);
upEnableDisable.ContentTemplateContainer.Controls.Add(disable);

AsyncPostBackTrigger enableTrigger = new AsyncPostBackTrigger();
enableTrigger.ControlID = enable.ID;
enableTrigger.EventName = "CheckedChanged";
upEnableDisable.Triggers.Add(enableTrigger);
AsyncPostBackTrigger disableTrigger = new AsyncPostBackTrigger();
disableTrigger.ControlID = disable.ID;
disableTrigger.EventName = "CheckedChanged";
upEnableDisable.Triggers.Add(disableTrigger);

mainDiv.Controls.Add(upEnableDisable);

在创建无线电台后,我与它们一起参加了<代码>Cecked Changed的活动。 然后,我把这些问题放在一个更新小组内。 我也试图创建两个<条码>AsyncPostBackTrigger,但那一条字不行。 您能否告诉我,上述法典有什么问题?

问题回答
RadioButton enable = new RadioButton();
enable.ID = "enable";
enable.Text = "Enable";
enable.AutoPostBack = true;
enable.GroupName = "enableDisableGroup";
enable.CheckedChanged += new EventHandler(enableRadioButton_CheckedChanged);

RadioButton disable = new RadioButton();
disable.ID = "disable";
disable.Text = "Disable";
disable.AutoPostBack = true;
disable.GroupName = "enableDisableGroup";
disable.CheckedChanged += new EventHandler(disableRadioButton_CheckedChanged);

UpdatePanel upEnableDisable = new UpdatePanel();
upEnableDisable.UpdateMode = UpdatePanelUpdateMode.Conditional;
upEnableDisable.ContentTemplateContainer.Controls.Add(enable);
upEnableDisable.ContentTemplateContainer.Controls.Add(disable);

AsyncPostBackTrigger enableTrigger = new AsyncPostBackTrigger();
enableTrigger.ControlID = enable.ID;
enableTrigger.EventName = "CheckedChanged";
upEnableDisable.Triggers.Add(enableTrigger);
AsyncPostBackTrigger disableTrigger = new AsyncPostBackTrigger();
disableTrigger.ControlID = disable.ID;
disableTrigger.EventName = "CheckedChanged";
upEnableDisable.Triggers.Add(disableTrigger);

mainDiv.Controls.Add(upEnableDisable);




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签