[CLOSED] [Razor] File upload field - bad response?

  1. #1

    [CLOSED] [Razor] File upload field - bad response?

    Hi, I'm trying to get upload file on server with file upload field with this code:


    @(Html.X().FormPanel().ID("PanelP1")
        .Items(items => {
            items.Add(Html.X().FileUploadField().ID("fuf1").Text("Add file"));
        })
        .Buttons(buttons =>
        {
            buttons.Add(Html.X().Button().ID("ButtonSave1").Text("Save").Icon(Icon.DatabaseSave)
                .DirectEvents(directEvents =>
                {
                    directEvents.Click.IsUpload = true;
                    directEvents.Click.Confirmation.ConfirmRequest = true;
                    directEvents.Click.Confirmation.Title = "Save";
                    directEvents.Click.Confirmation.Message = "Confirm?";
                    directEvents.Click.Url = "/Test/SaveR";
                    directEvents.Click.EventMask.ShowMask = true;
                    directEvents.Click.EventMask.Msg = "Loading...";
                })
            );
        })
    )
    And controller code is:

     public ActionResult SaveR()
            {
                try
                {
                    object o = Request.Files[0];
                    return (new AjaxResult { Script = X.Msg.Alert("Title", "Response test").ToScript() });
                }
                catch (Exception exc)
                {
                    return (new AjaxResult { Script = X.Msg.Alert("Title", "Error: " + exc.Message).ToScript() });
                }
            }

    In my object o I got file object. That is ok. Problem is because I have some error message on client after controller executes code.

    This is what I got as answer:

    Status Text: BADRESPONSE: Unexpected token <
    {script:"Ext.Msg.show({title:\"Title\",buttons:Ext.Msg.OK,msg:\"Response test\"});"}
    (In IE I got option to save file with this content.) Why server sends me this text as answer and how to fix this?

    Thanks!
    Last edited by Daniil; Jul 16, 2012 at 1:11 PM. Reason: Please use [CODE] tags for any code, [CLOSED]
  2. #2
    Hi,

    Please set up
    IsUpload = true
    for the AjaxResult.
  3. #3
    Thanks, that is solution! :)

Similar Threads

  1. File Upload Field - Multiple files?
    By peter.campbell in forum 1.x Help
    Replies: 2
    Last Post: Jul 04, 2012, 11:40 AM
  2. [CLOSED] Clone Upload File Field
    By imaa in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 17, 2011, 2:29 AM
  3. File Upload Field Problem
    By OSSAGHO in forum 1.x Help
    Replies: 0
    Last Post: Sep 19, 2011, 1:09 PM
  4. [CLOSED] File Upload Field
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Mar 30, 2010, 7:24 PM
  5. [CLOSED] File upload field in multifield.
    By pank in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 30, 2009, 9:09 PM

Tags for this Thread

Posting Permissions