How to display WebForms .ascx as partial view in MVC 3

后端 未结 3 1901
孤城傲影
孤城傲影 2021-01-06 13:56

I am building a new ASP.NET MVC 3 application. In this application, I would like to display an old WebForms user control (.ascx/.ascx.cs) in an overlay in my new MVC razor a

3条回答
  •  醉梦人生
    2021-01-06 14:10

    The long answer involves 'yes you can, but....'

    The short answer is, you shouldn't.

    Without knowing the specifics of your .ascx file, you can render a partial using

    @Html.Partial(PageName)
    

    But, if you have any server controls they will not work. MVC doesn't support the same kind of call back control state functionality. So, you are using any thing resembling

    
    

    then you're far better off re-factoring your partial.

提交回复
热议问题