A
Alexander Widera
I have a file "file1.cs" with a method:
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public static void justdoit()
{
string script = "<script language=\"JavaScript\"> alert("it works");
</script>";
Page.RegisterStartupScript("frreload", script);
}
If I use this method directly in an aspx-page it works.... But now the
problem: If I write this Method in a seperate file, because I want to re-use
this method in other aspx-pages, I get an error while compiling the file: "
error CS0120: An object reference is required for the nonstatic filed,
method, or property 'System.Web.UI.Page.RegisterStartupScript(string,
string)'
Where can I get the current "page-object", so that I can use the function
RegisterStartupScript ?
Thanks for help.
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public static void justdoit()
{
string script = "<script language=\"JavaScript\"> alert("it works");
</script>";
Page.RegisterStartupScript("frreload", script);
}
If I use this method directly in an aspx-page it works.... But now the
problem: If I write this Method in a seperate file, because I want to re-use
this method in other aspx-pages, I get an error while compiling the file: "
error CS0120: An object reference is required for the nonstatic filed,
method, or property 'System.Web.UI.Page.RegisterStartupScript(string,
string)'
Where can I get the current "page-object", so that I can use the function
RegisterStartupScript ?
Thanks for help.