Briskstar Technologies
Briskstar Technologies

Reputation: 2253

ASP.Net Usercontrol Event

I have usercontrol in my page loaded using Page.Controls.Add(ctrl)

Now, I have button in that user control and want to fire one function when user clicks on that user control's button.

I have that user control on lots of pages and want to fire different function on that button click of user control.

Upvotes: 0

Views: 1996

Answers (1)

Tim Schmelter
Tim Schmelter

Reputation: 460108

In general you should communicate from your UserControls to the Pages via Events. So declare a custom event in the UserControl that'll be raised in the button-click handler and can be handled by the page. On this way every page using this control can react differently.

http://www.codeproject.com/Articles/8797/Mastering-Page-UserControl-Communication#4.3

Upvotes: 1

Related Questions