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
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With