I’m attempting to create a custom control that inherits from System.Web.UI.WebControls.ListView. Codebehind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;
using System.Text;
namespace MyCompany.MyProject
{ //I've tried this without the "<T>" as well. Either seems to compile
//but neither works at runtime.
public partial class MyListView<T> : ListView
{
...
}
}
Markup:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyListView.ascx.cs" Inherits="MyCompany.MyProject.MyListView" %>
It all compiles, but when I try to load the page I get the following error:
“‘MyCompany.MyProject.MyListView’ is not allowed here because it does not extend class ‘System.Web.UI.UserControl’. at System.Web.UI.TemplateParser.ProcessError(String message)
at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly)
at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData) “
I have searched for quite some time trying to determine what is going wrong or for some kind of elegant work-around, but my searches have yielded nothing useful thus far.
Thanks in advance for taking the time to help me.
-A
Your problem is that your markup defines a
Controland aListViewis aWebControl.