我在一个aspx网页中有一个方法,它可以从另一个非网页的.cs类访问。该方法包含一个ClientScript来创建一个弹出窗口。static void客户端脚本
当我试图使它成为一个静态的时候,我得到下面这个错误。
的对象引用需要非静态字段,方法或属性“System.Web.UI.Page.ClientScript.get”
所以我想知道如果有一种方法从另一个.cs类或解决方案访问此方法。
基本上,当错误在.cs类上跳动时,我想显示一个说明错误的弹出窗口。
public static void message(string popupinformation)
{
ClientScript.RegisterStartupScript(this.GetType(), "", "popupinformation", true);
}
在的.cs
AddUI.message("alert('Error can not add information');");
发布两种方法的代码 –
我已添加代码 – user673906
我已编辑您的标题。请参阅:“[应该在其标题中包含”标签“](http://meta.stackexchange.com/questions/19190/)”,其中的共识是“不,他们不应该”。 –