Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 705
  • Last Modified:

How to handle the onClick or OnCheckedChanged Event for ASP.NET dynamatically created Button or Checkbox web form control?

How to handle the onClick or OnCheckedChanged Event for ASP.NET dynamatically created Button or Checkbox web form control?

I am a beginner of ASP.NET.

I can add Button or Checkbox control at design time, and handle the OnClick or OnCheckedChanged event without problem.

However, I really need to create Button or Checkbox controls at run time. In fact, I can do it without problem. My problem is how to handle the events for those dynamatically created controls. Can we do it? and if 'Yes', how?

I can to it with ASP 3.0 and JavaScript. But I want to do it in ASP.NET

Thanks.

0
zhuansun
Asked:
zhuansun
2 Solutions
 
mrwebdevCommented:
0
 
ihenryCommented:
Try this,

Dim myCheckbox As New System.Web.UI.WebControls.Checkbox()
AddHandler myCheckbox.CheckedChanged, AddressOf Me.myCheckbox_CheckedChanged

Dim myButton As New System.Web.UI.WebControls.Button()
AddHandler myButton.Click, AddressOf Me.myButton_Click
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now