Using derived/inherited components in C# / ASP.NET

L

Lauchlan M

Hi.

Following the example at
http://www.codeproject.com/useritems/ooaspnet.asp?print=true, I have a
datagrid descendant class that shows a JavaScript confirm dialog before
deleting a row from the grid.

My first two questions are:

(i) Currently this class is in my project namespace.

I suppose it's a good idea to have this in some more generic custom
namespace so I can use this in several ASP.NET projects.

What is the best way to take this component and do that?

(ii) Currently using the component involves dropping a normal datagrid on
the webform and then editing the HTML view of the designer

<%@ Register tagprefix="dg" Namespace="iCARnetWebInterface"
Assembly="iCARnetWebInterface" %>

and

<asp:Datagrid . . .> </asp:datagrid> to <dg:DelDataGrid> . . .
</DelDataGrid> eg:

<dg:DelDataGrid id="DataGrid1" runat="server" CellPadding="3"
BackColor="White" BorderWidth="1px"
BorderStyle="None" BorderColor="#CCCCCC" AllowPaging="True"
PageSize="8" AutoGenerateColumns="False"
Height="168px" Width="448px">
.. . .
</dg:DelDataGrid></TD>

How would I go about making this modified/descended/inherited component
available from the toolbar, so it registers itself and inserts itself into
the webform appropriately?

My third question would be how I would modify the grid so that if JavaScript
isn't available on the browser, it posts back a confirm message including a
yes and a no button and only deletes on the yes button being pressed.

All juicy questions, it seems . . .

Thanks!

Lauchlan M
 
S

S. Justin Gengo

Lauchlan,

Please see my responses inline:
Hi.

Following the example at
http://www.codeproject.com/useritems/ooaspnet.asp?print=true, I have a
datagrid descendant class that shows a JavaScript confirm dialog before
deleting a row from the grid.

My first two questions are:

(i) Currently this class is in my project namespace.

I suppose it's a good idea to have this in some more generic custom
namespace so I can use this in several ASP.NET projects.

What is the best way to take this component and do that?

You can create a new class library and then create a new component and
inherit the datagrid class. Then make your modifications as you have in the
current code.

(ii) Currently using the component involves dropping a normal datagrid on
the webform and then editing the HTML view of the designer

<%@ Register tagprefix="dg" Namespace="iCARnetWebInterface"
Assembly="iCARnetWebInterface" %>

and

<asp:Datagrid . . .> </asp:datagrid> to <dg:DelDataGrid> . . .
</DelDataGrid> eg:

<dg:DelDataGrid id="DataGrid1" runat="server" CellPadding="3"
BackColor="White" BorderWidth="1px"
BorderStyle="None" BorderColor="#CCCCCC" AllowPaging="True"
PageSize="8" AutoGenerateColumns="False"
Height="168px" Width="448px">
. . .
</dg:DelDataGrid></TD>

How would I go about making this modified/descended/inherited component
available from the toolbar, so it registers itself and inserts itself into
the webform appropriately?

If you create the new component and inherit the original datagrid class
as I mentioned above you will be able to add the new component to the
toolbar by right clicking on the toolbar, clicking the browse button in the
window that pops up, and navigating to the compiled .dll file of the new
component.

My third question would be how I would modify the grid so that if JavaScript
isn't available on the browser, it posts back a confirm message including a
yes and a no button and only deletes on the yes button being pressed.

To get you started I've modified the RequiredFieldValidator so that it
validates CheckBoxLists. It is inserting customized javascript on the page,
can be added to the toolbar, etc. It might give you some idea of how to get
started.

Just go to the code library and click the CheckBoxListValidator button in
the menu on the left.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top