views:

257

answers:

2

I understand that you can now create MVC-specific user controls, but will my existing standard ASCX user controls work in an MVC view?

I understand that MVC pages have a completely different lifecycle but will, for example, a Page_Load method be invoked as normal when the control is sitting in a view?

+1  A: 

If your standard ASCX controls do not have control events. There is no viewstate in MVC so that'll have to change.

The normal page lifecycle is still executed. E.g. Page load, init, prerender, etc. The main thing is viewstate.

Min
A: 

You can instantiate pre-built controls and call their RenderControl() method in order to use them in MVC views.

Stackoverflow does this for reCAPTCHA control rendering.

Also, the validation part is mapped to the route /captcha/post where the control is instantiated and the Validate() method is called.

So, essentially yes you can reuse your controls but you have to adapt to the architecture of MVC.

Franck