C# 非静态方法或字段错误需要对象
有 非静态字段、方法或对象需要对象引用 属性“System.Web.UI.Page.ClientScript.get”C# 非静态方法或字段错误需要对象,c#,jwplayer,C#,Jwplayer,有 非静态字段、方法或对象需要对象引用 属性“System.Web.UI.Page.ClientScript.get” 指定行中出现错误。如何修复?假设此代码来自页面本身,请尝试此操作 Type cstype = this.GetType(); ClientScriptManager cs = Page.ClientScript; ///Broken line if (!cs.IsStartupScriptRegistered(cstype, "load
指定行中出现错误。如何修复?假设此代码来自页面本身,请尝试此操作
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);
假设此代码来自页面本身,请尝试以下操作
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);
Page.ClientScript不是静态属性,因此不能以这种方式使用它。假设您有一个名为pageInstance的页面实例,该实例可以在方法中访问,请改用以下方法:
ClientScriptManager cs = this.ClientScript; ///Broken line
Page.ClientScript不是静态属性,因此不能以这种方式使用它。假设您有一个名为pageInstance的页面实例,该实例可以在方法中访问,请改用以下方法:
ClientScriptManager cs = this.ClientScript; ///Broken line
您正在尝试将播放机嵌入Windows phone应用程序或其他内容吗?您正在尝试将播放机嵌入Windows phone应用程序或其他内容吗?谢谢您的回答,但我现在收到了此错误。当前上下文中不存在名称“pageInstance”。应将“pageInstance”替换为页面实例的变量名。谢谢。现在没有错误。我有个问题。我该如何把它写进表格中。我想在此表单中运行jwplayer。谢谢您的回答,但我现在遇到了这个错误。当前上下文中不存在名称“pageInstance”。应将“pageInstance”替换为页面实例的变量名。谢谢。现在没有错误。我有个问题。我该如何把它写进表格中。我想在这个表单中运行jwplayer。