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'“
指定行中的错误。我该如何解决?
答案 0 :(得分:2)
假设此代码来自页面本身,请尝试使用此代码......
ClientScriptManager cs = this.ClientScript; ///Broken line
答案 1 :(得分:2)
Page.ClientScript
不是静态属性,因此您无法以这种方式使用它。假设您拥有名为Page
的{{1}}实例,该实例可以在方法中访问,请改用以下代码:
pageInstance