Wednesday, March 5, 2008

Events in User Control/Master Page


To communicate between UserControl / Master Page and the Container Page, normally we use Event Raise mechnaism. In this mechanism, we first declare the delegate and then an event of declared delegate type. Then on some event in UserControl/Master we raise our custom event.

Instead of getting into all such things better to use only the ‘Delegate’ approach as below.

Code in User Control:

private Delegate mSearchResult = null;

protected void btnSearch_Click(object sender, EventArgs e)




Code in container Page:

protected void Page_Load(object sender, EventArgs e)


delegate void SearchResult(Dto.Stipulation dtoStupulation);

SearchResult searchResultCall = new SearchResult(this.GetSearchData);

this.searchStipulation.SearchResult = searchResultCall;


private void GetSearchData(Dto.Stipulation dtoStupulation)



Thanks & Regards,

Arun Manglick || Tech Lead |

No comments:

Post a Comment