0

I need to use the AjaxHelper in my "code behind" but I'm having trouble with creating a new instance.

The constructor that I'd like to use looks like this:

public AjaxHelper (System.Web.Mvc.ViewContext viewContext, System.Web.Mvc.IViewDataContainer viewDataContainer);

and so far this is what I've got, not sure the first parameter is even correct..

var ajaxHelper = new AjaxHelper(this.ControllerContext.ParentActionViewContext,??);

How do I create a new AjaxHelper correctly?

Ninjanoel
  • 2,864
  • 4
  • 33
  • 53
  • 1
    if you can't send it in the parameters from an actual pageview, see here- https://stackoverflow.com/questions/17055626/pass-ajaxhelper-actionlink-from-the-server-to-the-view-in-a-model – TheMikeInNYC Nov 01 '19 at 19:30
  • Yeah I ended up doing all the work in the razor file, was hoping to make it more flexible by allowing the content to be built before using the view, but I've just gone with the simple solution to get the job done. – Ninjanoel Nov 04 '19 at 09:27
  • Follow the patterns, don't fight them. – TheMikeInNYC Nov 04 '19 at 14:42
  • if only i could instantiate the AjaxHelper then I'd have a great pattern, unfortunately now there may be cutting and pasting in the future. Did find others solving this problem in .net Core already. oh well – Ninjanoel Nov 04 '19 at 16:20

0 Answers0