加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

ASP.NET Kendo UI上传

发布时间:2020-12-16 04:18:31 所属栏目:asp.Net 来源:网络整理
导读:我想使用Kendo UI开发一个网站.我可以使用其他资格的kendo-ui.但是,我无法使用ASP.NET上传文件.是否有任何示例代码或文档可以解决此问题? 解决方法 以下是它对我有用的原因: JS: $(document).ready(function () { $(".attachmentUpload").kendoUpload({ a
我想使用Kendo UI开发一个网站.我可以使用其他资格的kendo-ui.但是,我无法使用ASP.NET上传文件.是否有任何示例代码或文档可以解决此问题?

解决方法

以下是它对我有用的原因:

JS:

$(document).ready(function () {
    $(".attachmentUpload").kendoUpload({
        async: {
            saveUrl: "SaveAttachment.aspx",autoUpload: true
        }
    });
});

页:

<input name="attachmentUpload" id="attachmentUpload" type="file" class="attachmentUpload" />

SaveAttachment.aspx.cs

public partial class SaveAttachment : Page
{
    protected void Page_Load(object sender,EventArgs e)
    {
        Response.Expires = -1;
        try
        {
            HttpPostedFile postedFile = Request.Files["attachmentUpload"];
            //do something with your postedfile
            Response.ContentType = "application/json";
            Response.Write("{}");
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());

        }
    }
}

SaveAttachment.aspx:

<%@ Page Language="C#" CodeBehind="SaveAttachment.aspx.cs" Inherits="Nstar.WebUI.Pages.SaveAttachment" EnableTheming="false" StyleSheetTheme="" Theme="" %>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读