I'm trying to execute a javascript function from a C# class in an asp.net application. I'm using the ScriptManager
. I have a class UpdateUI
, which contains the following method:
public static void RunScript()
{
try
{
if (HttpContext.Current != null)
{
Page currentPage = HttpContext.Current.Handler as System.Web.UI.Page;
ScriptManager.RegisterClientScriptBlock(currentPage, currentPage.GetType(), "disableControls", "disableControls()", true);
}
}
catch (Exception ex)
{
}
}
When I call UpdateUI.RunScript()
from another static class, the HttpContent.Current
is null
. Any idea how should I go in order to be able to execute the scriptmanager from a class which is not code-behind?