XMLDocument IE - Javascript

时间:2013-07-24 12:13:12

标签: javascript asp.net xml dom

我在Javascript中遇到XMLDocument对象的问题。它未定义或为null。我的aspx代码是

<div id='tabs_<%= RowId %>_2'>
    <table id='hist_<%= RowId %>'> //RowID is a number
     </table>
     <xml id='hist_data_<%= RowId %>'> //RowID is a number
        <%= GridData.ToString() %> //i have data in datagrid with xml format.
     </xml>
 </div>

我的脚本是

 function showCall(row_id){
    $("#hist_" + row_id).jqGrid({
    datatype: "xmlstring",
    datastr: document.all("hist_data_" + row_id).XMLDocument.xml // XMLDocument is undefined or null        
    });
}

我们的大多数客户使用IE9或早期版本的IE9。所以我在IE9中使用兼容模式进行调试。不太确定,因为一些文档/博客建议从IE9中删除XMLDocument。任何人都可以建议我解决这个问题的最佳方法吗?

编辑:

GridData xml设置 - C#后面的代码

 GridData = new XDocument(new XElement("root", rows = new XElement("rows")));
    foreach (Chronos.Messaging.CallStatus cs in Call.StatusList)
    {
        long s = cs.Duration;
        string duration = "";
        if (s > 0)
            duration = String.Format(@"{0:m:ss}", new DateTime(s * 10000000));
        bool rec = !String.IsNullOrEmpty(cs.MessageId);
        double rating = Admin ? WebServiceHelper.GetWebService().getCallRating(cs.ID) : 0;
        rows.Add(
            new XElement("row",
                new XElement("cell", cs.Timestamp.ToString("dd/MM/yy HH:mm:ss")),
                new XElement("cell", cs.AgentName),
                new XElement("cell", cs.Incoming ? (char)0x2713 : ' '), // 0x2713 is tick mark
                new XElement("cell", TelephoneNumberFormatter.Number(cs.NumberCalled)),
                new XElement("cell", duration),
                new XElement("cell", rec & !survey ? "<a href='Listen.aspx?id=" + cs.MessageId + "'>" + cs.DialResultDescription + "</a>" : cs.DialResultDescription),
                new XElement("cell", survey ? "" : cs.Info),
                new XElement("cell", rating > 0 ? String.Format(@"<input type=""button"" value=""{0} %"" onclick=""window.open('CallRating.aspx?callStatusID={1}&callID={2}','Rating','status=1,resizable=1,scrollbars=1,width=590,height=650');return false;"" />", rating.ToString(), cs.ID, Call.ID) : String.Format(@"<input type=""button"" value=""Rate"" onclick=""window.open('CallRating.aspx?callStatusID={0}&callID={1}','Rating','status=1,resizable=1,scrollbars=1,width=590,height=650');return false;"" />", cs.ID, Call.ID))
                ));
    }

0 个答案:

没有答案