[RESOLVED]Render Dynamic Forms model in Razor View

Hi,

 

Im using Dynamic Forms in ASP.NET MVC sample project from this link https://mvcdynamicforms.codeplex.com/  to be used in my MVC 5 project.

 

Waht i need is to call the dynamically generated Form model to be rendered in razor view as it is currently rendered in asp.net mvc ViewPage.

here’s the current Model,Controller and how the view has called the Form object. How can i call the form object in mvc 5 razor view.

 

FormProvider Model

=================================

    public static class FormProvider

    {

        public static Form GetForm()

        {

        }

    }

 

 

HomeController

===========================

    public ActionResult Demo1()

        {

          

             var form = FormProvider.GetForm();

             

              form.Serialize = true;

             return View("Demo", form);

     }

 

 

 

ASP.NET MVC View

==================

 

     <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcDynamicForms.Form>" %>

 

     <asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">

 

 

      <%Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data" }); %>

   

 

      <%=Model.RenderHtml(true) %>

   

          <input type="submit" value="Submit" />

           <%Html.EndForm(); %>

 

        </asp:Content>

@model MvcDynamicForms.Form
@{
    // set layout if required etc
}
@using(Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data" })){ 
    @Model.RenderHtml(true)  
    <input type="submit" value="Submit" />
}

Thanks Mike. it worked…!

@Model.RenderHtml(true)  didn't render the html, instead it displays the string as is, but when it is wrapped in HTML.Raw(Model.RenderHtml) 
it did work.


Leave a Reply