Calling a method in parent page from user control

前端 未结 10 1171
暖寄归人
暖寄归人 2020-11-28 23:01

I\'ve a user control registered in an aspx page On click event of a button in the user control, how do i call a method which is there in the parent page\'s code

10条回答
  •  独厮守ぢ
    2020-11-28 23:23

    I suggest you don't call the page method directly, as you would be tying your control to the specific page.

    Instead expose an event, and have the page subscribe to it. It works for any number of pages, can more easily be used when the control is multiple times on a single page (perhaps even on a list) and is more in line with asp.control design.

提交回复
热议问题