volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More. 

volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More. 

Forms loaded via ajax call

Hi 

I have an problem with loading forms via ajax call. In project we have an form which will be dispalyed on dialog. When rendering partial view during ajax call exception occurs :

[NullReferenceException: Object reference not set to an instance of an object.]
   EPiServer.Forms.Controllers.FormContainerBlockController.RegisterResources(List`1 scripts, List`1 css) +872
   EPiServer.Forms.Controllers.FormContainerBlockController.RegisterScriptResources(FormContainerBlock formContainerBlock) +160
   EPiServer.Forms.Controllers.FormContainerBlockController.Index(FormContainerBlock currentBlock) +502
   lambda_method(Closure , ControllerBase , Object[] ) +141
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +279
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +34
   System.Web.Mvc.Async.<>c__DisplayClass42.

Unfortunetly we are using quite old version of forms (4.3.0) and we can't upgrade to higer version :( 

Because as I understand problem i with loading some scripts or other dependent content.

So question is have somebody struggled with this problem. Or know how partial view should be created to enable forms on modal popup loaded via xjax?

Right now partial view is quite simple :

@model SubscribeOverlayViewModel

@Html.PropertyFor(m => m.SubscribeBlock.FormsArea)

Have an nice day :)

#190688
Apr 16, 2018 9:35

Can you provide us your implementation code so that we can have a look ?

#190810
Edited, Apr 17, 2018 12:32

Hi Quan

Javascript is standard jQuery call for partial view.

On server site we have standard ASP.MVC controller

 public class SubscribeOverlayController : Controller

with Index Action :

 public ActionResult Index(int contactPageId, string currentCulture)
        {
            var contactPage = BaseDependencies.ContentRepository.Get<ContactPage>(new PageReference(contactPageId), new LanguageSelector(currentCulture));
            return PartialView("~/Views/Partial/SubscribeOverlay.cshtml", new SubscribeOverlayViewModel(contactPage, currentCulture));
        }

And during rendereing :

@Html.PropertyFor(m => m.SubscribeBlock.FormsArea)

We recive above errors. 

FormsArea implementaion :

[Display(Name = "Forms", Description = "Insert forms", GroupName = TabGroupNames.EpiForms)]
        [AllowedTypes(typeof(FormContainerBlock))]
        [AllowedBlocks(new[] { typeof(FormContainerBlock) })]
        [CultureSpecific]
        public virtual ContentArea FormsArea { get; set; }

I understand that probelm is probably in partial view rendereing. And i iam trying to find some solution. 

#190821
Edited, Apr 17, 2018 14:30

Partial view cannot be rendered in itself. Do you have the parent view referencing this view? 

#190864
Apr 17, 2018 21:33

In stanard templated view yes, but as i have mentioned in my first post this view is recived by axax call. 

In this situation I have an button, on clik we make asynchronous (via jQuery $.ajax() method) call for partial view

#190879
Apr 18, 2018 9:17
* 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.