user310291
user310291

Reputation: 38190

How to reference a scriptmanager from HttpContext.Current.CurrentHandler?

I reference the current page in a class with

Page page = HttpContext.Current.CurrentHandler as Page;

I know need to reference ScriptManager1. What the syntax ?

Thanks.

Upvotes: 1

Views: 1047

Answers (2)

m3kh
m3kh

Reputation: 7941

Or

Page page = HttpContext.Current.CurrentHandler as Page;

if (page != null)
{
    ScriptManager smgr = ScriptManager.GetCurrent(page);
}

Upvotes: 6

TheGeekYouNeed
TheGeekYouNeed

Reputation: 7539

ScriptManager sm = (ScriptManager)page.FindControl("ScriptManager1");

if(sm != null)
{
    // Control found

}

Upvotes: 3

Related Questions