Type cstype = this.GetType();
ClientScriptManager cs = Page.ClientScript; ///Broken line
if (!cs.IsStartupScriptRegistered(cstype, "loadvideo"))
{
StringBuilder cstext3 = new StringBuilder();
cstext3.Append("jwplayer(\"vidplayer\").setup({");
cstext3.Append("flashplayer:\"./players/player.swf\",");
cstext3.Append("file: \"");
cstext3.Append("./video.mp4");
cstext3.Append("\",height: 270,");
cstext3.Append("width: 400");
cstext3.Append("});");
cs.RegisterStartupScript(cstype, "loadvideo", cstext3.ToString(), true);
有
“非静态字段,方法或属性'System.Web.UI.Page.ClientScript.get'”需要对象引用
指定行中的错误 . 我该怎么办?
2 回答
假设此代码来自页面本身,请尝试使用此代码...
Page.ClientScript
不是静态属性,因此您不能以这种方式使用它 . 假设您有Page
实例,名为pageInstance
,可以在方法中访问,请使用以下代码: