Thursday, July 14, 2011

ASP.NET

how to access the usercontrol's property or method()


SearchUsercontrol is a usercontrol. The requirement is to access a usercontrol’s method or property from the parent aspx page.

For normal aspx pages (with out master pages)

Usercontrol1.Method() or userconrol.GetID

For normal aspx pages (with master page)

SearchUsercontrol _displayResultsUserControl = _contentPlaceHolder.FindControl("SearchResults") as SearchUsercontrol;

_displayResultsUserControl.methpdname()
_displayResultsUserControl.propertyName;



Similarly to access the a ASPX page’s method or property from the usercontrol


SearchResults myparentPage = (SearchResults)this.Page;
myparentPage.BindRadGrid();


Here SearchResults is the Usercontrool

No comments: