Abstract ASPXs

R

Richard Thomas

Hi,

I've got an .aspx page with a number of controls on it for setting the
values for an object. When the values have been put in, the user
clicks on the "Store" button.

When I want to edit an instance of this object, I've got a second page
which is a direct copy of the first, but some of the code has been
changed so that, for example, the Store button now says "Update".

The Java programmer in me says that I should have an abstract version
of this page, and then put the Store/Update specific functionality in
subclasses. I've done this in the following way:

1) Created the page "AbstractRecordPage.aspx" with an associated
"AbstactRecordPage.aspx.cs". This page contains the controls etc. I've
declared the page abstract.
2) Declared abstract methods like "getActionButtonText" and
"actionButton_Click" in AbstractRecordPage.aspx.cs
3) Made two classes, both of which are subclasses of
AbstractRecordPage, named StoreRecordPage.cs and UpdateRecordPage.cs.
They implement the abstract methods declared in the parent class.

All of this works at compile time. However, how do I specify which
subclass of AbstractRecordPage should be used in, for example, a
hyperlink?

Do I just link to "UpdateRecordPage.aspx" even though that particular
page doesn't really exist, or is it more complicated than that?

Thanks in advance for your help

Richard
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi Richard

I have never do it , but what you can do is insert a new class in the
project, it would be your parent class, make this class inherit from Page as
usual, code here all your functionality as usual.
Now add a web form, in the code behind change the parent of the class
created from Page to your base class, doing so you will have the
functionality of the parent form.
Do the same with the other page.

I don;t think that you need to change somethign else, if so you may need to
change from private to protected some methods, but again, I'm not sure of
it.

Cheers,
 

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

Top