I am trying to call a js function implemented on an aspx page from a .cs class. But ScriptManager does not seem to exist in the .cs class. Basically, the .cs file is part of the dll that I use in my project. I need to call the js function, which is implemented on an aspx page, from my .cs file present in the dll.
The js function runs successfully from the aspx page, but when I try to use the same code in the .cs file, it says
ScriptManager is unavailable due to its level of protection.
here is the code i am trying
protected void MyMethod() { ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "jsfunction();", true); }
any ideas why the same code works successfully on an aspx page but not from the .cs class?
source share