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

XForm events in MVC project

Vote:
 

I am working on an MVC site which has an XForm form on one of the pages. 

I added code in the global.asax.cs file like it is done here:

protected void Application_Start(Object sender, EventArgs e)
{

   // some code here

    XFormControl.ControlSetup += new EventHandler(XForm_ControlSetup);
}
public void XForm_ControlSetup(object sender, EventArgs e)
{
    XFormControl control = (XFormControl)sender;

    control.BeforeLoadingForm += new LoadFormEventHandler(XForm_BeforeLoadingForm);
    control.ControlsCreated += new EventHandler(XForm_ControlsCreated);
    control.BeforeSubmitPostedData += new SaveFormDataEventHandler(XForm_BeforeSubmitPostedData);
    control.AfterSubmitPostedData += new SaveFormDataEventHandler(XForm_AfterSubmitPostedData);
}
public void XForm_ControlsCreated(object sender, EventArgs e)
{
	XFormControl formControl = (XFormControl)sender;
    // the rest of the code here
}


and the other event handlers below ....

The view:

@model PageViewModel

x.CurrentPage.PageName)>@Model.CurrentPage.PageName

x.CurrentPage.MetaDescription)>@Model.CurrentPage.MetaDescription
@Html.PropertyFor(m => m.CurrentPage.Form)

Model:

[ContentType(DisplayName = "Formulärsida", GUID = "066267cd-af44-47db-a7e3-6aec27543d6c", Description = "")]
public class FormsPage : EditorialPage
{
    [CultureSpecific]
    [Display(
        Name = "Formuläret",
        Description = "Formuläret",
        GroupName = SystemTabNames.Content,
        Order = 1)]
    [Required]
    public virtual XForm Form { get; set; }
}


Controller:

public class FormsPageController : PageController
{
	public ActionResult Index(FormsPage currentPage)
	{
		PageViewModel vm = new PageViewModel(currentPage);
		return View(vm);
	}
}

I attach to the IIS process, and add breakpoints in all the XForm events in the global.asax.cs file, go to the page having the XForm form and assumed that the events would be triggered. They are not.

Any suggestions why?

Thanks for any kind of guidance!! 

#114292
Dec 09, 2014 11:57
Vote:
 

Thank you for your reply.

I tried your solution but with the same result. :(

#114298
Dec 09, 2014 14:08
* 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.