Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Dynamic Content and ViewUrl in MVC?

Vote:
 

I'm trying to make an XForm dynamic content in EPiServer 7 MVC but I can't really get it to work.

At the moment I've created a class which looks like this:

    [DynamicContentPlugIn(DisplayName = "XForms", ViewUrl = "~/Views/Shared/DynamicContent/XFormView.cshtml")]
    public class XForms : DynamicContentBase, IDynamicContentView
    {
        public XForms()
        {
            Properties = new PropertyDataCollection {{"XFormControl", new PropertyXForm()}};
        }

        public virtual void Render(TextWriter writer)
        {
            writer.Write("<div>Hello world</div>");
        }
    }

With this i was hoping that the file specified in the ViewUrl property would be rendered but all that will render is the "Hello world" in the Render method. Can someone give me some guidance on how I can load  this view or give tips on how to load an xform control in the render method?

#75839
Oct 08, 2013 14:28
Vote:
 

What happens if you remove the Render method?

#75840
Oct 08, 2013 16:05
Vote:
 

That's not possible since I implement IDynamicContentView

#75841
Oct 08, 2013 16:13
Vote:
 

What happens if you remove IDynamicContentView? I did something similar a while a go and I couldn't have both the render method and the ViewUrl as one canceled out the other.

#75842
Oct 08, 2013 16:14
Vote:
 

Ah yes you're righ! When i removed that interface i was able to render the view. Now just to figure out how to render the xform object from the model which is a dynamic content :)

#75844
Oct 08, 2013 16:23
Vote:
 

any luck with this one? 

wheni delete IDynamicContentView it complains it not compatible with MVC

But when it is included it wont go to my view ".cshtml" and onyl runs Render

#147451
Apr 14, 2016 16:44
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.