Theomax
Theomax

Reputation: 6810

ASP.NET How to handle User Control Event in page that contains the User Control?

I have a page that that contains a User Control and a submit Button. The User Control contains a Drop Down List.

I want to make the Button on the page visible if the user selects an item in the User Control's Drop Down List.

How can I make the page recognise the Drop Down List OnSelectedIndexChanged event?

Upvotes: 2

Views: 2695

Answers (2)

IUnknown
IUnknown

Reputation: 22478

Add own event to your UserControl and subscribe on it in page's code-behind. In SelectedIndexChanged event handler fire your event if somebody subscribe on it. Detailse explanation with code you may find here: Easily Raise Events From ASP.NET ASCX User Controls

Upvotes: 2

Nitin Rastogi
Nitin Rastogi

Reputation: 1456

Expose a custom public event in your user control - MySelectedIndexChanged. Subscribe to this event in your page class. Effectively delegates and events.

Read more on MSDN

Upvotes: 3

Related Questions