Dynamically (programatically) adding check boxes and checkedchanged events

前端 未结 8 506
情歌与酒
情歌与酒 2020-12-19 18:21

I am having a bit of a problem adding a few check boxes and an event handler programatically. The check boxes all appear fine, but they don\'t do anything when clicked. Does

8条回答
  •  臣服心动
    2020-12-19 18:46

    When you say they "don't do anything" - are you getting the postback?

    I wouldn't be surprised if you had to assign IDs to the checkboxes - bear in mind that on the postback, you'll get a new page, so it'll have to recreate all the checkboxes, then work out which one was checked etc. This is getting into what is (to me, anyway) somewhat black magic side of ASP.NET. I think you'll have to study the page life cycle and control identification side of things reasonably carefully.

提交回复
热议问题