PDA

View Full Version : [CLOSED] PartialViewResult with FormPanel does not show in FormCollection-Part 2



cynsystems
Jul 16, 2014, 8:42 PM
In my question posted on June 25th - I instituted the solution of adding RenderMode = RenderMode.AddTo when generating a PartialViewResult and everything thing was working perfectly -
Except the speed of the display of the PartialViewResult.
I modified my code to execute a ContentFromPartial instead of using a loader.
Displays instantly - but I'm back to my first problem. The elements of the partial view do not show up in the formcollection on submit.
(I'm guessing there is a way of specifying RenderMode = RenderMode.AddTo on the ContentFromPartial..but nothing I have tried works!)
Thanks!!!
Cyndi Pruett

The supporting class

public class Company
{
public int ID { get; set; }
public string strID { get; set; }
public string company { get; set; }
public string company_inPartialView { get; set; }
public string PartialViewName { get; set; }
}

the controller


public ActionResult Edit_Partial()
{
Company c = new Company();
c.strID = "1";
c.company = "test";
c.company_inPartialView = "test_inPartialView";
c.PartialViewName = "PartialView";
return View(c);
}
public ActionResult Save_Partial(FormCollection collection)
{
Company c = new Company();
c.PartialViewName = collection["PartialViewName"];

c.strID = collection["strID"];
c.company = collection["company"];
c.company_inPartialView = collection["company_inPartialView"];
return View("Edit_Partial", c);
}
public Ext.Net.MVC.PartialViewResult PartialView(string containerId)
{
Company c = new Company();
c.strID = "1";
c.company = "test";
c.company_inPartialView = "test_inPartialView";
c.PartialViewName = "PartialView";
return new Ext.Net.MVC.PartialViewResult
{
ContainerId = containerId,
ViewName = c.PartialViewName,
WrapByScriptTag = false,
Model = c,
RenderMode = RenderMode.AddTo
};
}


the view

@model tracker.Controllers.Company
@{
ViewBag.Title = "Edit_Partial";
Layout = "~/Views/Shared/_BaseLayout_orig.cshtml";
}

<h2>Edit_Partial</h2>
@section _body
{
@(Html.X().FormPanel() .ID("fp") .StandardSubmit(true).Width(1400).BodyPadding(5)
.TopBar(Html.X().Toolbar()
.Items(Html.X().Button().Text("Save").IconUrl("~/images/save.png").IconCls("x-btn-text-icon")
.DirectEvents(de =>
{
de.Click.Url = Url.Action("Save_Partial");
de.Click.EventMask.ShowMask = true;
de.Click.FormID = "fp";
})
)
)
.Items(
Html.X().Panel().ID("Panel1").ColSpan(1).Title("").Height(100).Width(400).MarginSpec("5 5 5 5")
.Items(Html.X().TextField().Name("strID").FieldLabel("strID").Value(Model.strID)
),
Html.X().Panel().ID("Panel2").ColSpan(1).Title("").Height(100).Width(400).MarginSpec("5 5 5 5")
.Items( Html.X().TextField().Name("PartialViewName").ID("PartialViewName").FieldLabel("PartialViewName").Value(Model.PartialViewName).Hidden(true),
Html.X().TextField().Name("company").ID("company").FieldLabel("company").Value(Model.company),
//Html.X().Container().ID("cPartialView").Loader(Html.X().ComponentLoader().Url(Url.Action ("PartialView")).Mode(LoadMode.Script) .Params(new { containerId = "cPartialView" })),
Html.X().Container().ID("cPartialView").ContentFromPartial(Model.PartialViewName, Model ).RenderTo("Panel2")

)
)
)
}

The PartialView

@using Ext.Net;
@using Ext.Net.MVC;

@model tracker.Controllers.Company

@Html.X().TextField().Name("company_inPartialView").ID("company_inPartialView").FieldLabel("company_inPartialView").Width(390).Value(Model.company_inPartialView)

Daniil
Jul 17, 2014, 2:27 PM
Hi @cynsystems,

Please try ItemsFromPartial (it is rendered as Items) instead of ContentFromPartial (it is rendered as raw HTML).


In my question posted on June 25th

Posting links in such cases might be useful.