因为它不扩展类'System.Web.UI.UserControl'

本文关键字:Web UI UserControl System 因为 扩展 | 更新日期: 2023-09-27 18:15:08

我已经创建了一个扩展DEVExpress ASPxGridView的用户控件。我的目标是让这个控件成为一个模板(样式设置,共享属性)所有的时间,我将但GridView某处,但不是必须添加属性和样式,我可以使用它作为一个模板。所有其他属性、事件等将从基类

继承。

这是我的asex .cs代码

namespace CORE.Web.UserControls
{
   public partial class ucGridView : DevExpress.Web.ASPxGridView.ASPxGridView
      {
      }
}

和ascx代码

<dx:ASPxGridView ID="gcGridView" runat="server" AutoGenerateColumns="False" Styles-AlternatingRow-Enabled="True">
<Settings HorizontalScrollBarMode="auto" VerticalScrollBarMode="auto" VerticalScrollableHeight="500" />
<SettingsPager PageSize="20">
    <PageSizeItemSettings Visible="true" ShowAllItem="true" />
</SettingsPager>
<SettingsBehavior AllowFocusedRow="true" />
<Styles>
    <Header VerticalAlign="Top" Wrap="True"></Header>
    <AlternatingRow Enabled="True"></AlternatingRow>
</Styles>

以及它在aspx页面中的位置

<uc1:ucGridView runat="server" ID="ucGridView" DataSourceID="masterStatsObjectDataSource" />

还有其他问题,如列和任何我知道要处理的,但我遇到了一个障碍,只是让它在运行时工作

我得到这个错误信息

CORE.Web.UserControls。ucGridView'在这里是不允许的,因为它不扩展类'System.Web.UI.UserControl'。

aspx页的第一行是

<%@控制语言=" c# " AutoEventWireup="true" CodeBehind=" ucgridview . asx .cs" Inherits="CORE.Web.UserControls. "ucGridView " %>

我不知道从这里去哪里,因为这应该很容易。任何帮助都将非常感激。

谢谢

因为它不扩展类'System.Web.UI.UserControl'

此控件可能不在当前命名空间中。

阅读:http://forums.asp.net/t/1557864.aspx?UserControl+is+not+allowed+here+because+it+does+not+extend+class+System+Web+UI+UserControl+

希望会有所帮助。

这不是最好的解决方案,但我决定创建一个继承所有属性和事件的Server Control。从那里开始,它直接进入了

相关文章: