creating custom web control .. any ideas ?

N

Nikolay Anestev

Hi all. In an ASP.NET application I want to make a DataGrid derrived class
named "MyDataGrid" which will encapsulate some common actions and then use
it in my pages instead of the DataGrid class.
When I rename the base class of any existing page member from:

public class MyPage : Page {

protected DataGrid DataGrid1;

..... }

, to:

public class MyPage : Page {

protected MyDataGrid DataGrid1;

..... }

a run-time error occurs:

Parser Error Message: The base class includes the field 'DataGrid1', but its
type (CSWebBankASP.MyDataGrid) is not compatible with the type of control
(System.Web.UI.WebControls.DataGrid).


So, I've added a "<%@ Register TagPrefix=uc2 Namespace=MyApp Assembly=MyApp
%>" directive at the top of the *.asp document and then changed the
"<asp:DataGrid>" tag to "<uc2:MyDataGrid>". In result this page works fine
already, but in the design view this DataGrid is not represented properly
( an error text occurs ) which tells me that there is something wrong in
this kind of technique.

So, does anyone have an idea how to do this without any errors? Just want to
tell you that using an UserControl doesn't work for me.

Thank you in advance. Best regards.

Nikolay Anestev
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top