且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将Webform控件转换为Razor语法

更新时间:2023-02-16 21:32:08

您不能在ASP.NET MVC应用程序中使用服务器端控件.尽管使用Razor的WebForms视图引擎仍然可以(但不建议这样做),但这不再可行.如果绝对需要调用服务器端控件,请尝试针对需要在其中调用控件的特定视图使用WebForms视图引擎.但是,如果此控件依赖于ViewState和PostBacks,它将无法正常工作.

You cannot use server side controls in an ASP.NET MVC application. While this was still possible (but not recommended) with the WebForms view engine with Razor this is no longer possible. If you absolutely need to call server side controls try using the WebForms view engine for the particular view in which you need to call the control. But if this control relies on ViewState and PostBacks it won't work.