November Happy Hour will be moved to Thursday December 5th.

XFORM

Vote:
 

I am using XForm for first time.

I have XFormTemplatePage as follows

[ContentType(DisplayName = "XFormPage", GUID = "de1ee296-9dcd-4d68-aad8-454d2d5f900f", Description = "")]
public class XFormPageTemplatePage : PageData
{
[CultureSpecific]
[Editable(true)]
[Display(
Name = "Formular",
Description = "Xform is used to get the user info.",
GroupName = SystemTabNames.Content,
Order = 4)]
public virtual XForm Formprop { get; set; }

---------------------------------------------------------

and i have XformPage.aspx as follows

<%@ Page Language="c#" Inherits="Totalkredit.EpiServer.Views.XFormPage" CodeBehind="XFormPage.aspx.cs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>XFormPage</title>
<style type="text/css">

hr {color:sienna;}
p {margin-left:20px;}
#name { color :red;}
.name { color :red;}
</style>
</head>
<body>
<form id="Form1" runat="server">
<div>
<%--@Html.PropertyFor(x => x.Formprop)--%>
<EPiServer:Property runat="server" PropertyName="Formprop" />
</div>
</form>
</body>
</html>

-------------------------------------------------------------------------

I get following error when i have created a simple form with 2 columns and save button  and click on save button. 

 

 

 

Server Error in '/' Application.
--------------------------------------------------------------------------------


The table tblXFormData does not appears to have any columns that can be used by the system. Is this really a 'big table'?
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The table tblXFormData does not appears to have any columns that can be used by the system. Is this really a 'big table'?

Source Error:


An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

 

[InvalidOperationException: The table tblXFormData does not appears to have any columns that can be used by the system. Is this really a 'big table'?]
EPiServer.Data.Dynamic.StoreDefinition.GenerateMappings(IEnumerable`1 typeBag, StoreDefinitionParameters parameters, Int32 version, IList`1 existingMappings, IDictionary`2 pendingRenames) +613
EPiServer.Data.Dynamic.<>c__DisplayClass6.<InternalCreate>b__3() +297
EPiServer.Data.Cache.LocalCache`2.Add(TKey key, Boolean cacheNullValues, Boolean overwriteExistingValue, Func`1 action) +171
EPiServer.Data.Dynamic.StoreDefinition.InternalCreate(String storeName, IDictionary`2 typeBag, StoreDefinitionParameters parameters) +360
EPiServer.Data.Dynamic.EPiServerDynamicDataStoreFactory.CreateStore(String storeName, IDictionary`2 typeBag, StoreDefinitionParameters parameters) +113
EPiServer.XForms.XFormData.CreateStore(Guid formId, IDictionary`2 typeBag, StoreDefinitionParameters parameters) +144
EPiServer.XForms.XForm.MapPostsStore() +1137
EPiServer.XForms.XForm.Save() +38
EPiServer.UI.Edit.XFormEdit.SaveForm(Boolean iClose) +299
EPiServer.UI.Edit.XFormEdit.SaveButton_Click(Object sender, EventArgs e) +35
EPiServer.UI.WebControls.ToolButton.OnClick(EventArgs e) +134
EPiServer.UI.WebControls.ToolButton.RaisePostBackEvent(String eventArgument) +193
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint

#72846
Jul 01, 2013 18:13
Vote:
 

I have never seen this error before. Is it a new EPiServer 7 site or is it upgraded from previous versions?

#72856
Jul 02, 2013 7:24
Vote:
 

it is a new episerver 7 site. is there any error in XFormPageTemplatePage or XformPage.aspx above?

 

#72863
Jul 02, 2013 9:49
Vote:
 

It is a Visual studio Episerver 7 MVC projekt

#72864
Jul 02, 2013 9:54
Vote:
 

There error seems to be related to saving the form and that has nothing to do the templates using the form. I suggest that you start a support case to investigate this since I have no clue why you are getting this error.

#72865
Jul 02, 2013 9:55
Vote:
 

If i look at the code it is not an MVC project since you are using webforms to create the template for showing the result. Try to connect your db to an empty episerver project based on webforms instead of mvc. 

#72867
Jul 02, 2013 10:09
Vote:
 

Thanks for your reply Eric.   It is actually a Mvc project.  as i am new to episerver and Xform, i thought also i am not doing it correctly.

So how should i write above code for mvc project? 

#72881
Jul 02, 2013 11:13
Vote:
 

Now i have used following as template

[ContentType(DisplayName = "XFormPageTemplate2", GUID = "4562c1f8-1abd-4f9b-95c7-8b985d31df66", Description = "XFormPageTemplate2")]
public class XFormPageTemplate2 : PageData
{
[Display(
Name = "XFormPageTemplate2",
Description = "XFormPageTemplate2 description",
GroupName = SystemTabNames.Content,
Order = 310)]
[CultureSpecific]
public virtual XForm XFormProperty2 { get; set; }
}

-----------------------------------------------------------

and i am using mvc 4 viewpage with layout (Razor) as follows

@model Totalkredit.EpiServer.Pages.XFormPageTemplate2
@using EPiServer.Core

@{
Layout = "~/Views/Shared/MasterLayout.cshtml";
}

<h1>Xform Template2 page </h1>


@Html.PropertyFor(x => x.XFormProperty2)

----------------------------------------------------------

still getting the same error when i have created a simple form with 2 columns with textbox  and button  

i get the error when i click on save button to save the form. 

 

#72884
Jul 02, 2013 12:01
Vote:
 

Try the below steps:

 

Page Type:

 

 [Editable(true)]
        [Display(
            Name = "Content",
            Description = "The Content will be shown in the main content area of the page.",
            GroupName = SystemTabNames.Content,
            Order = 4)]
        public virtual XhtmlString Content { get; set; }


        [Display(GroupName = SystemTabNames.Content, Order = 5)]
        public virtual XForm Form { get; set; }

Model:

  public virtual XForm XformContent { get; set; }

 

Base Controller class:

  //For XForm Page
        private readonly XFormPageUnknownActionHandler _xformHandler;
        private string _contentId;
        private readonly string _viewDataKeyFormat = "ViewData_{0}";
        private string ViewDataKey
        {
            get
            {
                return string.Format(_viewDataKeyFormat, _contentId);
            }
        }

        public BaseController()
        {
            _xformHandler = new XFormPageUnknownActionHandler();
            _contentId = string.Empty;
        }

  #region"XForm Block"

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (!string.IsNullOrEmpty(_contentId))
            {
                if (TempData[ViewDataKey] != null)
                {
                    ViewData = (ViewDataDictionary)TempData[ViewDataKey];
                }
            }

            base.OnActionExecuting(filterContext);
        }
        [AcceptVerbs(HttpVerbs.Post)]
        public virtual ActionResult Success(XFormPostedData xFormPostedData)
        {
            return RedirectToAction("Index");
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public virtual ActionResult Failed(XFormPostedData xFormPostedData)
        {
            return RedirectToAction("Index");
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public virtual ActionResult XFormPost(XFormPostedData xFormpostedData, string contentId)
        {

            //var formData = new XFormPageHelper().GetXFormData(this, xFormpostedData);
            // var result = XFormActionHelper.DoAction(formData, xFormpostedData, true);
            //return this.RedirectToAction("Index");
            _contentId = contentId;
            return _xformHandler.HandleAction(this);
        }
        #endregion

 

Controller:

 

 public ActionResult Index(CustomFormPageType currentPage)
        {

            var currentBlockID = (currentPage as IContent).ContentLink.ID;
            var viewDataKey = string.Format("ViewData_{0}", currentBlockID);

            if (TempData[viewDataKey] != null)
            {
                ViewData = (ViewDataDictionary)TempData[viewDataKey];
            }

            var pageRouteHelper = ServiceLocator.Current.GetInstance<PageRouteHelper>();
           // PageData currentPage1 = pageRouteHelper.Page;
            
            if (currentPage == null)
            {
                var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
                //currentPage = contentLoader.Get<StartPage>(ContentReference.StartPage);
            }
            var actionUri = string.Empty;
            if (currentPage.Form != null && currentPage != null)
            {
                var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();
                var pageUrl = urlResolver.GetVirtualPath(currentPage.ContentLink);

                actionUri = string.Format("{0}XFormPost/", pageUrl);
                actionUri = UriSupport.AddQueryString(actionUri, "XFormId", currentPage.Form.Id.ToString());
                actionUri = UriSupport.AddQueryString(actionUri, "failedAction", "Failed");
                actionUri = UriSupport.AddQueryString(actionUri, "successAction", "Success");
                actionUri = UriSupport.AddQueryString(actionUri, "contentId", currentBlockID.ToString());

                
            }

           
            var model = new CustomFormPageViewModel()
            {
               
                XformContent = currentPage.Form
             
            };

           

            return View(model);
        }

 

View:

   <section id="xform">
                    <div @Html.EditAttributes(m => m.XformContent)>
                @Html.ValidationSummary()
                @using (Html.BeginXForm(Model.XformContent, new { Action = Model.ActionUri }))
                {
                    Html.RenderXForm(Model.XformContent);
                }
            </div>
        </section>

 

More Information: Refer the URL below

http://blog.nansen.com/2013/03/creating-xform-block-in-episerver-7-mvc.html

 

 

#73231
Jul 11, 2013 6:40
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.