Find Control In ASP.NET Content Page

Standard

Hello everyone,

Have you ever tried to find an control using Page.FindControl() method in case that this page have a masterpage? if you answer is no, please try it and you will discover that this method won’t return any object, actually there is no direct way to make this.

Although the control is found in the page, ASP.NET consider that the control is located on the content placeholder control of the master page, so you have to get this control using the content place holder of the masterpage not the content control on the current page as following

Page.Master.FindControl(“ContentPlaceHolderID”).FindControl(“ControlName”);

Advertisements