Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i use Asp.Net WebForm User Controls in MVC Site?

I have a website in asp.net 4.0 with 10 pages and 12 user controls.

Now i want to migrate this site in asp.net MVC 4.0; So can I re-use those user controls (that are there in traditional asp.net) and render them using <%= Html.RenderUserControl() %>.

In short my question is whether we can use asp.net's user control in asp.mvc 4?

Many thanks,

JIgar

like image 243
Jigar Pandya Avatar asked Mar 15 '12 13:03

Jigar Pandya


People also ask

Can we use ASP.NET controls in MVC?

In ASP.Net you need to register one tagprefix and then use the user control by tagprefix registered but in ASP.Net MVC using simple Thml. RenderPartial we can use the user control.

Can we use webforms in MVC?

Luckily, the answer is yes. Combining ASP.NET Webforms and ASP.NET MVC in one application is possible—in fact, it is quite easy. The reason for this is that the ASP.NET MVC framework has been built on top of ASP.NET.

What is user control in ASP.NET MVC?

An ASP.NET Web user control is similar to a complete ASP.NET Web page (. aspx file), with both a user interface page and code. You create the user control in much the same way you create an ASP.NET page and then add the markup and child controls that you need.

Which is better webform or MVC and why explain?

Asp.Net Web Form has built-in data controls and best for rapid development with powerful data access. Asp.Net MVC is lightweight, provide full control over markup and support many features that allow fast & agile development. Hence it is best for developing an interactive web application with the latest web standards.


1 Answers

You generally can't use asp.net controls in a MVC application. Almost all controls require view state, which ASP.NET MVC doesn't support.

like image 57
RickAndMSFT Avatar answered Oct 07 '22 18:10

RickAndMSFT