Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# jquery插件已加载,但';无法访问';网络控制_C#_Jquery_Jquery Plugins_Web Controls - Fatal编程技术网

C# jquery插件已加载,但';无法访问';网络控制

C# jquery插件已加载,但';无法访问';网络控制,c#,jquery,jquery-plugins,web-controls,C#,Jquery,Jquery Plugins,Web Controls,我在制作固定表头时遇到问题。我发现了一个jQuery插件,它在简单测试中运行良好。但我需要将其作为嵌入式资源包含在WebControl中 所以我在Assembly.cs中注册了脚本,并将它们设置为“嵌入式资源” 在网络控制中,它们的注册方式如下: this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "jquery", Page.ClientScript.GetWebResourceUrl(this.GetTyp

我在制作固定表头时遇到问题。我发现了一个jQuery插件,它在简单测试中运行良好。但我需要将其作为嵌入式资源包含在WebControl中

所以我在Assembly.cs中注册了脚本,并将它们设置为“嵌入式资源”

在网络控制中,它们的注册方式如下:

 this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "jquery",  Page.ClientScript.GetWebResourceUrl(this.GetType(), "LRGrid.jquery_min.js"));

 var fixedScript = Page.ClientScript.GetWebResourceUrl(this.GetType(), "LRGrid.jquery_fixedheadertable.js");

 this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "fixedheadertable", fixedScript);

 this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "jquery",  Page.ClientScript.GetWebResourceUrl(this.GetType(), "LRGrid.jquery.tablescroll.js"));
然后,为了调用脚本,我执行以下操作:

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SetTable" + ClientID, "; $(document).ready(function(){$('table#" + ClientID + "').fixedHeaderTable({ footer: false, cloneHeadToFoot: false, fixedColumn: false });});", true); 
现在,如果我在FireFox中测试它,我会得到

.fixedTableHeader is not a function
IE9告诉我
方法不受支持

我可以使用FireBug或IE开发者工具栏查看脚本是否已加载?!?!?关于为什么它不可用有什么想法吗

编辑:: 现在,我已经尝试直接在标记中加载脚本,然后按照预期工作。但是,一旦我尝试使用嵌入式资源加载它们,它就会失败,并且无法将
fixedTableHeader
识别为一个函数

$(document).ready(function () { 
    if(jQuery.isFunction($('table#" + ClientID + "').fixedTableHeader)){
      $('table#" + ClientID + "').fixedTableHeader({ height:200, width:'100%' });
    }else{
      alert('unable to load scroll script');
    }
});

好的-因此错误位于另一个文件中。。。真倒霉

我已经从一个基本页面加载了jQuery(或者有人曾经这么做过;)

当我尝试在那里加载jQuery时,这与我的控件冲突。。。现在我不想从这两个位置删除jQuery初始化。所以我决定让BasePage加载有条件。由于BasePage了解
LRGrid
,但不了解其他方面

这就是解决方案:

if (!Page.ClientScript.IsClientScriptIncludeRegistered(typeof(LRGrid.LRGrid), "jquery"))
      {
        Page.ClientScript.RegisterClientScriptInclude(
             typeof (WebPageBase), "jQuery", ResolveUrl("~/Scripts/jquery-1.4.1.js"));
      }

希望你们中的一些人可以使用它:-p

请给我们看一下元素出现的HTML片段好吗?我的想法是,您试图匹配的ID的构造方式与您的脚本所要查找的不同(sure@RobAllen-任何可能有助于澄清这一点的内容;)表标记是:
,脚本呈现如下:
$(document).ready(函数(){$('table#grid')).fixedHeaderTable({footer:false,cloneHeadToFoot:false,fixedColumn:false})
if (!Page.ClientScript.IsClientScriptIncludeRegistered(typeof(LRGrid.LRGrid), "jquery"))
      {
        Page.ClientScript.RegisterClientScriptInclude(
             typeof (WebPageBase), "jQuery", ResolveUrl("~/Scripts/jquery-1.4.1.js"));
      }