【发布时间】:2015-11-20 07:01:32
【问题描述】:
我在我的 Mvc 布局页面中集成 Asp.net 用户控件(.ascx),即母版页,我正在使用剃须刀引擎。
错误:执行处理程序的子请求时出错
'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper ascx.
Control '1_hdfData' of type 'HiddenField' must be placed inside a form tag with runat=server.
这是我的代码:
_Layout.cshtml:
@Html.Partial("~/UserControls/Data.ascx")
Data.ascx:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Data.ascx.cs" Inherits="MyNameSpace.Data" %>
<asp:HiddenField ID="hdfData" runat="server" />
--Rest all other asp.net server side controls---.
Data.ascx.cs:
namespace MyNameSpace.Data
{
public partial class Data : ViewUserControl
{
//Page_Load events and other code
}
}
如果我从ViewUserControl 继承用户控件(.ascx),我是否无法使用 asp.net 控件?
谁能帮我解决这个问题?
【问题讨论】:
-
只需要在usercontrol中添加form标签
-
我喜欢这个话题,很有趣:)
标签: c# asp.net asp.net-mvc webforms user-controls