only My site

Wednesday, July 30, 2008

Master Page - Tips

When using masterPage system, i can't access the "ScriptManager1" object within the codebehind of ContentPage file..
You access the scriptManager from a content page using the static GetCurrent method:

ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);

Also we can use Type casting..

if (((MasterPage)Master).FindControl("ScriptManager1") != null)
{
ScriptManager scm;
scm = (ScriptManager)((MasterPage)Master).FindControl("ScriptManager1");
scm.SetFocus(txtHdrDet_CMNumber);
}

No comments: