Success response from C#

2 posts, 1 answers
  1. Answer
    Erick
    Erick avatar
    2 posts
    Member since:
    Jul 2013

    Posted 24 Sep 2013 Link to this post

    Hi

    I'm trying to use the kendo upload web control with C#, I can upload the controls is always on error, I know that I have to return an empty response but I don't know exactly how. This is my javascript

    <script>
                $(document).ready(function () {
                    $("#files").kendoUpload({
                        async: {
                            saveUrl: "Attachments.aspx",
                            removeUrl: "remove",
                            autoUpload: true
                        }
                    });
                });
            </script>

    and on C# I have

    protected void Page_Load(object sender, EventArgs e)
        {
            HttpFileCollection x = Request.Files;

            if (x.Count>0)
            {
                Response.Clear();
                Response.ContentType = "application/json";
                Response.Write("{}"); 
            }
        }

    I tried with Response.Write("") to with and without contentype but it didn't work.

    Do anyone know how to build the correct success response?
  2. Erick
    Erick avatar
    2 posts
    Member since:
    Jul 2013

    Posted 24 Sep 2013 Link to this post

    I finally found my solution

    I was using Response.clear() on the load event of my aspx page, so at the end the response had all the html for that page because it was rendered anyway, so I built a different page to use as response and overwrote the render method with an empty method and that did the trick, this is the C# code

    Main page (the one with the upload control, that in my case I am using it to retrieve the files too)
    protected void Page_Load(object sender, EventArgs e)
            {
                HttpFileCollection x = Request.Files;
               
                if (x.Count > 0)
                {
                        //code to retrive the files
                        Server.TransferRequest("Response.aspx");
                }
            }


    Response.aspx.cs

    protected void Page_Load(object sender, EventArgs e)
            {

            }
            protected override void Render(HtmlTextWriter output)
            {
            }
  3. Kendo UI is VS 2017 Ready
Back to Top