2017-09-17 27 views
1

我有一個遺留的ASP.NET Web窗體應用程序,它有一個Web服務來檢索json中的數據。此外,發送到此Web服務的數據將作爲json發送。 Web服務是一個真正的ASPX頁面,獲取數據作爲發佈表單數據:具有自定義JSON Web服務器的Kendo UI網格 - 「未捕獲的TypeError:this.replace不是函數」

json = Server.UrlDecode(Request.Form.ToString()) 

在劍道的UI我傳遞的參數如下:

transport: { 
    read: { 
     url: "MyService.aspx", 
     dataType: "json", 
     type: "POST", 
     data: JSON.stringify(GetRequestParams()) 
    } 
} 

JSON.stringify的值(GetRequestParams ())是

"{"Header":{"Method":"getfiles"},"Body":{"Data":{},"MaxResults":10,"PageNum":"1","FolderID":"14","SearchString":"","SearchSubFolders":false,"DepartmentID":"333333"},"ApiBaseUrl":"/Api3/"}" 

然而,這提供了以下JavaScript錯誤:「未捕獲類型錯誤:this.replace是不是一個函數」 如果我通過數據,而不字符串化我t個第一,不會有一個JavaScript錯誤,但在服務器端,而不是JSON,我得到:

$inlinecount=allpages&Header[Method]=getfiles&Body[MaxResults]=10&Body[PageNum]=1&Body[FolderID]=14&Body[SearchString]=&Body[SearchSubFolders]=false&Body[DepartmentID]=333333&ApiBaseUrl=/Api3/&GetAjaxData=&$top=20 

有沒有人有一個想法如何,我可以通過使用傳輸自定義的數據對象。使用Kendo-UI讀取選項,這樣我就可以解碼服務器端的數據對象而沒有問題?

或者任何建議的方式與asp.net形式以任何其他方式完成此任務?

+0

你有沒有想過什麼?我與MVC項目有同樣的問題 –

回答

0

我確實找到了解決辦法,但不是100%,因爲我最終沒有使用Kendo。我可以從我的代碼,我沒有看到的是:

來傳遞數據:data: GetRequestParams()(不字符串化)

在後面的代碼我會確定這是否從劍道來到這個(VB.Net):

If (Request.Form("Header[Method]") IsNot Nothing AndAlso Request.Form("Header[Method]").ToLower() = "getfiles") Then 
     KendoRequest = True 
Else 

而且比得到的參數是這樣的:

If Request.Form("Body[PageNum]") IsNot Nothing Then 
    PageNum = Convert.ToInt32(Request.Form("Body[PageNum]")) 
End If 

If Request.Form("Body[FolderID]") IsNot Nothing Then 
    FolderID = Convert.ToInt32(Request.Form("Body[FolderID]")) 
End If 

不漂亮,但它的工作。

相關問題