ASP.NET MVC Beta 1 - will my existing custom controls work as they are in my views?

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

I understand that MVC pages have a completely different lifecycle, but for example, would the Page_Load method be called as usual when the control is in the view?

0


source to share


2 answers


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



The normal page life cycle is still running. For example. Page loading, init, prerender, etc. The main thing is the viewstate.

+1


source


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

Stackoverflow does this for rendering the reCAPTCHA control.



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

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

0


source







All Articles