【问题标题】:Issues with Kendo MVVM file upload controlKendo MVVM 文件上传控制问题
【发布时间】:2015-03-21 15:57:04
【问题描述】:

我试图让 Kendo MVVM 文件上传与 ASP.NET 一起工作。这是我的 HTML 查找上传声明的方式:

<input name="attachments" 
id="fileUpload"
type="file"
data-role="upload"
data-async="{ saveUrl: 'FileUpload.aspx', autoUpload: true }"
data-bind="events: { success: onSuccess,error: onError }">

和 FileUpload 页面加载:

Response.Expires = -1;

//Code to upload -- This returns me the file url that i need to send back as a response
Response.ContentType = "text/plain";
Response.Write(fileUrl);
Response.End();

上面编写的页面加载确实按预期运行并返回了我想要的结果,但这里的剑道控件的行为方式很有趣。它告诉我上传不成功,因为用户界面上显示了错误图标。此外,它是由 Kendo 提供的错误处理程序,尽管当我尝试访问它时正确返回了书面响应:

e.XMLHttpRequest.responseText

好吧,我想我可能在这里或那里错过了一些东西/犯了一些小错误,但不幸的是我无法弄清楚。谁能建议/纠正?

【问题讨论】:

    标签: asp.net file-upload kendo-ui kendo-mvvm kendo-upload


    【解决方案1】:

    看来文件上传控件的响应应该为空或 JSON 字符串,否则将被视为错误。我将响应文本更改为:

    Response.Write(new JavaScriptSerializer().Serialize(fileUrl));
    

    解决。

    希望这对其他人有帮助!

    【讨论】:

      猜你喜欢
      • 2011-09-29
      • 1970-01-01
      • 1970-01-01
      • 2013-10-24
      • 2011-05-01
      • 2019-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多