Is there a webform control on the asp.net mvc view page?

Can an asp.net mvc view page have a webform control on it?

I think I read about this before, but I'm not sure how this will work, since MVC does not use viewstate, etc.

+4
source share
4 answers

It can, but ViewState is not available. So, if the control depends on the state of the view, it may not work correctly.

In addition, events will not be available.

+6
source

I know for sure that any control that implements IPostBackEventHandler or IPostBackDataHandler will automatically work - they will throw an exception in which you need <form runat="server">

However, you should avoid using ASP.NET WebForms server controls in your MVC applications.

+1
source

Do not forget that MVC implements REST, so ViewState is now quite deprecated if you do not implement it yourself using hidden fields.

The fact that WebForm management was good was Ajax IMHO.

If you replace WebForm controls with partial views, WebControl classes, and jQuery plugins, you can do the same.

Currently, I tend to write my own WebControls and jQueryPlugins and reference them in PartialViews.

Heaps of jQuery plugins are now available that perform almost all the actions that WebForm controls performed.

+1
source

Not most web controls because they depend on ControlState and in some cases ViewState. Third parties, such as Telerik, adapt their controls to get around this, however the long-term goal is for people to create new controls that are more built on standards like JavaScript, jQuery, JSON, etc.

0
source

All Articles