我已經開發了一個asp.net網站,在它的大部分頁面中,我使用的是庫的cliend網站,以及web方法在服務器端。我的asp.net網站上的ajax錯誤
當我在本地計算機上運行我的站點時,是正確的,但是當我將其上載到我的主機上時,大部分ajax請求都會出錯。
這是一個例子:
EX:我有一個彈性工作網格,希望將數據加載到它時,文件準備好,但和錯誤uccurred和我的螢火蟲抓住它:
The method 'FetchCountryList' returns a value of type 'System.Xml.XmlDocument', which
cannot be serialized as Xml. Original error: Unable to generate a temporary class
(result=1). error CS2001: Source file 'C:\WINDOWS\TEMP\d2h0eyni.0.cs' could not be
found error CS2008: No inputs specified
我需要幫助解決這個錯誤
這是我在客戶端代碼:
$("#GrdCountry").flexigrid({
url: 'CountryDefinition.aspx/FetchCountryList',
dataType: 'xml',
colModel: [
{ display: 'Name', name: 'Name', width: 210, sortable: true, align: 'left' },
{ display: 'Code', name: 'Code', width: 100, sortable: true, align: 'left' },
{ display: 'Capital', name: 'Capital', width: 210, sortable: true, align: 'left' },
{ display: 'Actions', width: 100, align: 'Center'}],
buttons: [
{ name: 'Add', bclass: 'add', onpress: addOpr },
{ separator: true}],
searchitems: [
{ display: 'Name', name: 'Name', isdefault: true },
{ display: 'Capital', name: 'Capital'}],
sortname: "Name",
sortorder: "asc",
usepager: true,
//title: 'Countries',
useRp: true,
rp: 10,
resizable: false,
showTableToggleBtn: false,
width: 783,
height: 330
});
,這是我在服務器端代碼:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
public static XmlDocument FetchCountryList(int page, int rp, string sortname, string sortorder, string query, string qtype)
{
CountryBL CountryBLO = new CountryBL();
XDocument xmlDoc = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XElement("rows",
new XElement("page", page.ToString()),
new XElement("total", CountryBLO.Load().Count.ToString()),
CountryBLO.Load(page, rp, sortname, sortorder, query, qtype).Select(row => new XElement("row", new XAttribute("Id", row.Id.ToString()),
new XElement("cell", row.Name.ToString()),
new XElement("cell", row.Code.ToString()),
new XElement("cell", row.Capital.ToString()),
new XElement("cell", "<img id='imgEdit' lang='" + row.Id.ToString() + @"' style='cursor:pointer;border:0px;' src='../../Storage/Images/FlexGrid/edit.png' />
<img id='imgDelete' lang='" + row.Id.ToString() + "' style='cursor:pointer;border:0px;' src='../../Storage/Images/FlexGrid/delete.gif' />")
)
)
)
);
return Tools.XDocumentToXmlDocument(xmlDoc);
}
謝謝,阿里
如何爲我的問題分配賞金! –