[CLOSED] PartialViewResult with FormPanel does not show in FormCollection part 2

  1. #1

    [CLOSED] PartialViewResult with FormPanel does not show in FormCollection part 2

    I am using MVC/Razor to display a webpage with a partial view result based a field in the model.
    I am expecting the fields in the partial view to be part of the FormCollection but they are not included in the returned collection.
    I'm just wondering what I am doing wrong?

    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);
            }
    View Edit_Partial.cshtml
    @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")
    
                                               )
                                   )
                   )
    }
    partial view PartialViewName.cshtml
    @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)
    _BaseLayout_orig.cshtml
    @{
        Layout = null;
    }
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=100">
    
    <html>
    <head>
        <title>@ViewBag.Title</title>
    
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        @if (IsSectionDefined("headtag"))
        {
            @RenderSection("headtag", false)
        }
    </head>
    <body>
        @Html.X().ResourceManager(ViewBag.ManagerConfig as MvcResourceManagerConfig)
        @RenderBody()
    
        @if (IsSectionDefined("_body"))
        {
            @RenderSection("_body", false)
        }
        @if (IsSectionDefined("example"))
        {
            @RenderSection("example", true)
        }
        @Scripts.Render("~/bundles/jquery")
        @RenderSection("scripts", required: false)
    </body>
    </html>
    ps - I was using a component loader as in
    http://http://forums.ext.net/showthr...FormCollection
    But the loading was very slow. This method loads at the same time as the form - but the fields on the partial view are not included in the post back form collection...

    THanks!!!
    Cyndi Pruett
    Last edited by Daniil; Jul 31, 2014 at 5:31 AM. Reason: [CLOSED]
  2. #2
    Hi

    Please use ItemsFromParrtial (instead ContentFromPartial) and remove RenderTo
  3. #3
    That was what I was doing wrong!
    Thanks!
    Cyndi Pruett

Similar Threads

  1. Replies: 1
    Last Post: Jul 17, 2014, 2:27 PM
  2. [CLOSED] PartialViewResult with FormPanel does not show in FormCollection
    By cynsystems in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 26, 2014, 5:03 PM
  3. Replies: 1
    Last Post: Nov 29, 2012, 9:33 AM
  4. Replies: 2
    Last Post: Jul 12, 2012, 2:06 PM
  5. [CLOSED] Layout School Part III: Why doesnt the UserControl show up
    By wagger in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: May 20, 2011, 8:10 AM

Posting Permissions