PDA

View Full Version : [CLOSED] parsedResponse.result - Error on form submit with file upload field



OriCoder
Jan 06, 2015, 1:25 PM
Hi there,

I have a partial view that contains a form, within the form is a file upload field which handles the uploading of files seperately, on submitting the form I am getting


TypeError: parsedResponse.result is undefined

...cope.parseResponse(response,options);if(!Ext.is Empty(parsedResponse.result.docum...


ext.axd?v=33683 (line 128, col 62)

The Controller code is



namespace Ext.Net.MVC.Sample.Controllers
{
[DirectController(AreaName = "Events")]
public class ExtNetController : Controller
{


public ActionResult Index()
{

ExtNetModel model = new ExtNetModel()
{
WindowTitle = "ERROR",
TextAreaEmptyText = ">> Enter a Message Here <<",
sME = "Steven McCullie"
};
string sUser = "Steven McCullie";
X.GetCmp<ToolbarTextItem>("sUser").Text = sUser;

return View();
}



#region Counterparties

public PartialViewResult CounterpartiesOld(string containerId)
{
return new PartialViewResult
{
ContainerId = containerId,
ViewName = "Counterparties4",
WrapByScriptTag = false
};
}



public ActionResult UpdateIdentity(FormCollection values, string user)
{

// alert to user to show that identity has been updated
X.Msg.Notify("Counterparty Ammended", values["ComplianceNote"]).Show();

return this.Direct(); // parser error here....
}


}
}
#endregion


The partial view is

@{
ViewBag.Title = "Counterparties4";
}
<div>

@(
Html.X().Panel()
.Layout(LayoutType.Border)
.MinWidth(1500)
.Height(810)
.Items(

Html.X().Panel()
.Region(Region.Center)
.MinWidth(1000)
.Flex(2)
.AutoScroll(true)
.Items(
Html.X().TabPanel()
.Title("Counterparty Details")
.ID("CounterpartyDetailTabs")
.Items(
Html.X().Panel()
.Title("Identity")
.ID("IdentityTab")
.Border(false)
.Items(
Html.X().FormPanel()
.AutoScroll(true)
.Layout(LayoutType.HBox)
.Items(
Html.X().FormPanel()
.Layout(LayoutType.Border)
.Width(950)
.Height(800)
.ID("IdClientInfo")
.Items(

Html.X().FieldSet()
.Border(false)
.Height(700)
.Width(950)
.Padding(0)
.MarginSpec("5 5 5 0")
.Region(Region.South)
.Items(
Html.X().FieldSet()
.Title("Counterparty Files")
.Height(600)
.Width(475)
.Region(Region.East)
.Items(
Html.X().FileUploadField()
.FieldLabel("Upload File Attachments")
.Name("FileAttachment")
.ID("FileAttachment")
.Padding(5)
.Width(430)
)
,
Html.X().FieldSet()
.Border(false)
.Width(950)
.Region(Region.South)
.Items(
Html.X().Button()
.Text("Save Changes")
.Icon(Icon.Lightning)
.Height(50)
.Padding(5)
.DirectEvents(de =>
{

de.Click.Url = Url.Action("UpdateIdentity");
de.Click.ExtraParams.Add(new Parameter("values", "this.up('form').getForm().getValues(true)", ParameterMode.Raw));
de.Click.ExtraParams.Add(new Parameter("User", "X.getElementById(\"sUser\").innerHTML", ParameterMode.Raw));
}
)
)
)
)
)
)
)
)
)
)
</div>

The index.cshtml file which holds the partial view is


@*@model Ext.Net.MVC.Sample.Models.ExtNetModel*@
@model System.Collections.IEnumerable
@using OMS.Models
<!DOCTYPE html>

<html>

<head>


<script src="../../JS/CounterpartyTab.js" type="text/javascript"></script>

</head>

<body>
@Html.X().ResourceManager()





@(
Html.X().Viewport()

.Layout(LayoutType.VBox)
.LayoutConfig(
new VBoxLayoutConfig { Align = VBoxAlign.Stretch }
)

.Items(regions =>
{
regions.Add(Html.X().Panel()
.ItemID("north")
.Height(27)
.Header(false)
.Border(false)
.TopBar(Html.X().Toolbar().Items(items =>
{
items.Add(new ToolbarTextItem { Text = "You are logged in as:" });
items.Add(new ToolbarTextItem { ID = "sUser", Text = "" });
items.Add(new ToolbarSpacer());

}
)
)
)
;
regions.Add(Html.X().TabPanel()
.Flex(1)
//.ActiveTabIndex(3)
.Items(tabs =>
{


// Counterparty tab page
tabs.Add(Html.X().Panel()
.Title("Counterparties")
.Layout(LayoutType.HBox)
.LayoutConfig(new HBoxLayoutConfig { Align = HBoxAlign.Stretch })

.Items(blag =>
{
blag.Add(
Html.X().Container()
.ID("counterpartiesOld")
.StyleSpec("border:solid 1px black;")

.Border(false)
.Loader(Html.X().ComponentLoader()
.Url(Url.Action("CounterpartiesOld"))
.Mode(LoadMode.Script)
.Params(new { containerId = "counterpartiesOld" })
)
);
}
)
);


})
);


}

)
)


</body>
</html>


Thanks

Dimitris
Jan 06, 2015, 3:02 PM
Hello,

Unfortunately I cannot run your code. Can you please narrow down your sample a bit and make sure it builds and runs autonomously? (And I think you can spare the partial view since it does not seem to be part of the problem).

As a side note, shouldn't there be a form tag like:

<form id="form1" enctype="multipart/form-data">

OriCoder
Jan 12, 2015, 12:35 PM
Hi,

No need for the form tags, the submit works perfectly when the file upload field is not present.

What compile error are you getting? The partial view is where there form is so this is required although I could move to the index file if I thought that wasnt an issue.

To create your own, make a form with the file upload field and one other value with a submit button, you will find (or at least I have) that the file upload field causes the parser error when the submit button is clicked.

Daniil
Jan 13, 2015, 5:00 AM
IsUpload should be set to true for a DirectResult, if there is an upload operation.

Please try:

public ActionResult UpdateIdentity(FormCollection values, string user)
{
// alert to user to show that identity has been updated
X.Msg.Notify("Counterparty Ammended", values["ComplianceNote"]).Show();
DirectResult r = new DirectResult { IsUpload = true };

return r;
}

OriCoder
Jan 13, 2015, 8:21 AM
Thanks Daniil,

Please mark this thread as closed.