开发者

Using ASP.net Server control In MVC

I am using ASP.Net MVC for my project. Can we use asp.net web controls (like Dropdown, GridView etc.) in MVC? I开发者_运维技巧f yes, how? Do I have to create a separate assembly and refer it to my project or is there any other way out?


You can certainly use server controls in you MVC web site. You just reference the assemblies with the controls you wish to use your MVC web site project. You can then use the server controls to render in your views.

Remember though MVC has no veiw state or page life cycle like web forms does. So the server controls will not work the same way when you post back as they do in web forms.

Hope this helps.


You can, but then you violate the fundamental principles of MVC. Well sort of. If you want to use controls then just do WebForms project. MVC was not made to be misused.


I'm sure you can, but I would suggest against it, I'm sure you will run into some strange problem eventually. Do you have a really compelling reason to do this, as opposed to using the MVC helper methods (e.g. Html.TextBox(..) etc)?


You can not use WebForms controls in MVC due to the lack of ViewState and the differences in the way postbacks are handled. This is reflected in the scramble that vendors like Telerik and DevExpress are experiencing trying to get MVC versions of their libraries out.

Now - is it possible to create a workaround that allows you to use a WebForms control? Well, sure. But that isn't the same thing as just using a WebForms control. Indeed, the workarounds I saw from Telerik when they released their first MVC-based controls were pretty complex.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜