Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/423.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.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# getElementsByTagName返回null_C#_Javascript_Jquery_Html_Asp.net - Fatal编程技术网

C# getElementsByTagName返回null

C# getElementsByTagName返回null,c#,javascript,jquery,html,asp.net,C#,Javascript,Jquery,Html,Asp.net,我得到一个错误: 无法调用null的方法“getElementsByTagName”。 警报#1会弹出,警报#2会弹出,但很明显,要么调用creategvHeader要么调用build headers失败,我从未看到警报#3 我还试着输入#错误并不意味着返回null。该错误表示您试图调用null值上的getElementsByTagName。呈现页面时,您是否可以在页面上(查看源代码或在浏览器开发工具中)看到id=“gvheader”的元素?getElementById(“dummyHeader

我得到一个错误:

无法调用null的方法“getElementsByTagName”。

警报#1会弹出,警报#2会弹出,但很明显,要么调用create
gvHeader
要么调用build headers失败,我从未看到警报#3


我还试着输入
#错误并不意味着返回null。该错误表示您试图调用
null
值上的
getElementsByTagName
。呈现页面时,您是否可以在页面上(查看源代码或在浏览器开发工具中)看到
id=“gvheader”
的元素?
getElementById(“dummyHeader”)
是返回null的元素。您试图引用的div的ID可能由于母版页/内容页的原因而被修改。为它分配一个客户机ID,或者您也可以使用一个唯一的类名,并以此取而代之。
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Main.Master" AutoEventWireup="true" CodeBehind="CraigTest.aspx.cs"  Inherits="OfficeIntranet.Forms.Purchasing.CraigTest" %>  
<%@ Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit,
     Version=4.1.51116.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" %>    

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">  
<script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> 
<script src="../../Scripts/jquery.tablesorter.js" type="text/javascript"></script>
<link href="../../Styles/StyleSheet.css" rel="stylesheet" type="text/css" /> 

<script type="text/javascript">
    $(document).ready(function () {  
        $("#<%=gvOrderDetails.ClientID%>").tablesorter();  
        alert("Are we here 1?");  
        SetDefaultSortOrder();  
        alert("Are we here 4?");
    });

    function Sort(cell, sortOrder) {
        var sorting = [[cell.cellIndex, sortOrder]];
        $("#<%=gvOrderDetails.ClientID%>").trigger("sorton", [sorting]);
        if (sortOrder == 0) {
            sortOrder = 1;
            cell.className = "sortDesc";
        }
        else {
            sortOrder = 0;
            cell.className = "sortAsc";
        }
        cell.setAttribute("onclick", "Sort(this, " + sortOrder + ")");
        cell.onclick = function () { Sort(this, sortOrder); };
        document.getElementById("container").scrollTop = 0;
    }

    function SetDefaultSortOrder() {
        var gvHeader = document.getElementById("dummyHeader");
        alert("Are we here 2?");
        var headers = gvHeader.getElementsByTagName("th");
        alert("Are we here 3?");
        for (var i = 0; i < headers.length; i++) {
            headers[i].setAttribute("onclick", "Sort(this, 1)");
            headers[i].onclick = function () { Sort(this, 1); };
            headers[i].className = "sortDesc";
        }
    }
</script>  

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderBody" runat="server">       
<asp:UpdatePanel ID="UpdatePanelSPA" runat="server" UpdateMode="Always">    
    <ContentTemplate>
        <div id="headerE" runat="server" style="text-align: center; width: auto;">
            <asp:Label ID="MainH" CssClass="headerText" runat="server">SPA Order Control</asp:Label>
            <asp:Label ID="headVersion" CssClass="textarea" runat="server"></asp:Label>                
        </div>
        <asp:Panel ID="PanelDetails" runat="server" Width="960px" Style="margin-left: 20px;" Visible="false">
            <div class="container" id="DetailsSection">                    
                <div>
                    <table class="tablesorter" id="dummyHeader" rules="all"; style="width:940px; height:25px; border-collapse:collapse">
                        <col style="width:78px" />
                        <col style="width:225px" />
                        <tr style="background-color: LightGrey; height:25px; font-weight:bold; border-width:1px; border-color:Gray"/>
                            <th scope="col">Item Code</th>
                            <th scope="col">Description</th>
                        </tr>
                    </table>
                    <div style="height:550px; width:942px; overflow:auto;">
                        <asp:GridView ID="gvOrderDetails" runat="server" ShowHeader="false"
                            AlternatingRowStyle-BackColor="#FAFAFA" Width="924px" 
                            AutoGenerateColumns="False" AllowSorting="True" OnSorting="SortOrderDetails"
                            OnRowCommand="gvOrderDetails_RowCommand" EmptyDataText="No Data to Display"
                            DataKeyNames="STOREORDNUM" HeaderStyle-Height="22px" 
                            onselectedindexchanged="gvOrderDetails_SelectedIndexChanged">
                            <AlternatingRowStyle BackColor="White" />
                            <EditRowStyle BackColor="#2461BF"/>
                            <FooterStyle BackColor="LightGray" Font-Bold="False" ForeColor="Black" />
                            <HeaderStyle BackColor="LightGray" Font-Bold="False" ForeColor="Black" BorderWidth="1px" BorderColor="Gray"/>
                            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                            <RowStyle BackColor="#EFF3FB" Height="22px"/>
                            <Columns>
                                <asp:BoundField DataField="ITMCD" HeaderText="Item Code" >
                                    <ItemStyle CssClass="gvAlignCenter5pxR" Width="78px" />
                                </asp:BoundField>
                                <asp:BoundField DataField="DESC" HeaderText="Description" >
                                    <ItemStyle CssClass="gvAlignLeft5pxR" Width="232px"/>
                                </asp:BoundField>
                            </Columns>                        
                        </asp:GridView>
                    </div>
                </div>
            </div>                                
        </asp:Panel>          
    </ContentTemplate>
</asp:UpdatePanel>
</asp:Content>