stopcode.net

Dave Knipper Was Here

How to Use Old ASP.NET Web Form Server Controls in ASP.NET MVC applications

Here's how to use old ASP.NET Web Form server controls within ASP.NET MVC applications. The following will use an MVC Html Helper to call a static method on a server control. This method will render the control in the background and return the HTML to the ASP.NET MVC application.

1. Modify you ASP.NET Web Form server control. Add a static method that will return the ASP.NET Web Form server control's markup. This method will take arguments for any properties you need to fill in the ASP.NET Web Form server control to make it render properly (or anything else). 2. Create the MVC Html Helper Extension. This method will call the GetMyServerControlControlMarkup(string innerText) method above and return the MyServerControl's Html Markup. 3. Use in the view: