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:

Comments (1) -

  • july Pham

    8/14/2018 10:46:01 PM |

    This article is depressing -- I seem to be the only one that likes WebForms. I don't use viewstate or post-backs or control panels, but I sure like using "this.TextBox" in the CodeBehind. Razor syntax always seems like a jumble of HTML and logic. I've always like putting plain HTML on the page, and doing the logic in the code behind. So easy.
    Reference website: