Hi,
I've created a default asp.net web page and dragged a DataGrid inside it.
I would like to create a simple custom class derived from DataGrid to hide
all relevant code in it, instead of putting the code (especially for the
events) in the _default class.
This class is called DGMGrid2. I replaced the declaration :
protected System.Web.UI.WebControls.DataGrid DataGrid1;
with
protected DGMGrid2 DataGrid1;
public class DGMGrid2 : System.Web.UI.WebControls.DataGrid
{
public void DMGrid2() {}
}
That should work ?
It compiles OK but when executed there is a parse error:
Parser Error Message: The base class includes the field 'DataGrid1', but its
type (Foo.DGMGrid2) is not compatible with the type of control
(System.Web.UI.WebControls.DataGrid).
Error:
Line 20: <ASP:DATAGRID enableviewstate="false" id="DataGrid1"
runat="server" showfooter="False" width="100" cellpadding="2" pagesize="100"
autogeneratecolumns="False" horizontalalign="Center">
What is the right way to do that ?
Thanks !! 5 1121
"SoftLion" <no****@replyToGroup.com> wrote in message
news:uv**************@TK2MSFTNGP10.phx.gbl... Hi, I've created a default asp.net web page and dragged a DataGrid inside it. I would like to create a simple custom class derived from DataGrid to hide all relevant code in it, instead of putting the code (especially for the events) in the _default class.
This class is called DGMGrid2. I replaced the declaration : protected System.Web.UI.WebControls.DataGrid DataGrid1; with protected DGMGrid2 DataGrid1;
public class DGMGrid2 : System.Web.UI.WebControls.DataGrid { public void DMGrid2() {} }
That should work ? It compiles OK but when executed there is a parse error:
Parser Error Message: The base class includes the field 'DataGrid1', but
its type (Foo.DGMGrid2) is not compatible with the type of control (System.Web.UI.WebControls.DataGrid). Error: Line 20: <ASP:DATAGRID enableviewstate="false" id="DataGrid1" runat="server" showfooter="False" width="100" cellpadding="2"
pagesize="100" autogeneratecolumns="False" horizontalalign="Center">
What is the right way to do that ?
Your .aspx page is referencing an ASP.NET DataGrid (type
System.Web.UI.WebControls.DataGrid), but you are actually using a DGMGrid2.
You should register your DGMGrid2 class (as "mine", for instance), then
reference "<mine:DMGrid2 ... />" in the .aspx page.
Also, remove the empty constructor. You don't want a return type in a
constructor, and the system-supplied default constructor will do the same
thing anyway.
--
John Saunders
johnwsaundersiii at hotmail
> Your .aspx page is referencing an ASP.NET DataGrid (type System.Web.UI.WebControls.DataGrid), but you are actually using a
DGMGrid2. You should register your DGMGrid2 class (as "mine", for instance), then reference "<mine:DMGrid2 ... />" in the .aspx page.
Ok here is my new class:
public class DGMGrid2 : System.Web.UI.WebControls.DataGrid
{
}
And here is the Register directive:
<%@ Register TagPrefix="LocalGrid" Namespace="MyMainPage"
assembly="MyMainPage" %>
And here is the replacement tag :
<LocalGrid:DMGrid2 .... />
New error:
Could not load type MyMainPage.DMGrid2 from assembly MyMainPage,
Version=1.0.1627.25616, Culture=neutral, PublicKeyToken=null.
I don't want to create a nwe file for this class, nor a new special
assembly. I want to use the current page file. Any simple way to do this ?
Thks!
"SoftLion" <no****@replyToGroup.com> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl... Your .aspx page is referencing an ASP.NET DataGrid (type System.Web.UI.WebControls.DataGrid), but you are actually using a DGMGrid2. You should register your DGMGrid2 class (as "mine", for instance), then reference "<mine:DMGrid2 ... />" in the .aspx page.
Ok here is my new class: public class DGMGrid2 : System.Web.UI.WebControls.DataGrid { }
And here is the Register directive: <%@ Register TagPrefix="LocalGrid" Namespace="MyMainPage" assembly="MyMainPage" %>
And here is the replacement tag : <LocalGrid:DMGrid2 .... />
New error: Could not load type MyMainPage.DMGrid2 from assembly MyMainPage, Version=1.0.1627.25616, Culture=neutral, PublicKeyToken=null.
I don't want to create a nwe file for this class, nor a new special assembly. I want to use the current page file. Any simple way to do this ?
Is your application called "MyMainPage"? If not, then that's not the right
name for the assembly. You need to specify the <appname>.dll file in your
bin folder.
--
John Saunders
johnwsaundersiii at hotmail
> Is your application called "MyMainPage"? If not, then that's not the right name for the assembly. You need to specify the <appname>.dll file in your bin folder.
yes it is.
It appears there is no way to do this simply,
WebForms are just not as easy as MFC, ATL or WinForms.
B.
"SoftLion" <no****@replyToGroup.com> wrote in message
news:e3*************@TK2MSFTNGP09.phx.gbl... Is your application called "MyMainPage"? If not, then that's not the
right name for the assembly. You need to specify the <appname>.dll file in
your bin folder.
yes it is. It appears there is no way to do this simply, WebForms are just not as easy as MFC, ATL or WinForms.
Ok, so you're saying there's a MyMainPage.dll in your bin directory?
--
John Saunders
johnwsaundersiii at hotmail This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Owatona |
last post by:
Hi to all...
I have 3 classes derived from webcontrol.
I the first i have two dropdownlist, in the second i have some buttons, and the third its the webcontrol that are instanciate the two...
|
by: Matthew |
last post by:
hi dear members, i have derived my aspx code behind class from a
'BasePage'.in this BasePage, i put some formatting functions in it. I also
write some customer controls, in one control, i have to...
|
by: Lucas, Todd |
last post by:
Hello everyone! I'm having a problem with a WebControl that I'm designing
for a Menu. I've been at it for about 3 weeks now, and can't seem to get
around this problem. So I'm hoping that someone...
|
by: Nathan Sokalski |
last post by:
I want to make sure that the SelectedDate property of the Calendar control
is later than the current date or that a certain checkbox is selected. I
tried to use a CustomValidator control with the...
|
by: antonyliu2002 |
last post by:
I am new to the .NET framework.
I know this has been discussed many times in this group. I also read
extensively here, however, I am in bad luck: none of the sample code
provided in this forum...
|
by: J'son |
last post by:
Guys,
I have created a custom class that derives from DataList so that I can
add some custom client side functionality into each new item row
(<td>). Heres the class in its simplest form:
...
|
by: Lloyd Dupont |
last post by:
I'm trying to play with ASP.NET and I have some problem understanding how to
solve some problem, I wonder if I get it all wrong...
As an exercise for my firsts ASP.NET work I decided to write a...
|
by: Peter Rilling |
last post by:
Okay, I something weird is happening where I do not know if I am doing
something wrong.
I have a page that contains a custom webcontrol that I developed. This
webcontrol basically loads a...
|
by: ThunderMusic |
last post by:
Hi,
I have a custom WebControl. I fire an event and send, as the EventArg,
another WebControl that contains sub controls (ParseChildren(true))... It
can contain anything, but I want to find one...
|
by: JJ |
last post by:
Using asp.net 1.1
I am trying to have a consistent look for the webcontrols. Right now, every
time I use textbox controls, I manually change the font property, size
property, and other property...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |