Inheriting local variables from a common source?

  • Thread starter Thread starter Wayne J
  • Start date Start date
W

Wayne J

I have 3 pages, each with 2 tables (tblNew and tblConfirm), because these 2
tables are affected by the same code, I thought if I used an inherited class
defining these variables along with the code, it would work.

It does, to a point, but everytime I hit "Save" I will see errors pile up
thanks to conflicting variable names.

On the code-behind for the pages, VS will fill in the variable names even
though I have already declared them in the inheritted class.

Doesn't VS traverse the inherited list or are these ignored and only used at
compilation?
 
Hi All

I think a good case study will be a big help in learning OOAD. Does anyone
have a COMPLETE Case Study? I have been searching it for years and got
nothing till today.

A complete case study should have:
1. A clear Problem Description or Requirement.
2. Object-Oriented Analysis in UML diagrams.

Regards
Amit Chaudhary
 
Wayne J said:
I have 3 pages, each with 2 tables (tblNew and tblConfirm), because these 2
tables are affected by the same code, I thought if I used an inherited class
defining these variables along with the code, it would work.

It does, to a point, but everytime I hit "Save" I will see errors pile up
thanks to conflicting variable names.

On the code-behind for the pages, VS will fill in the variable names even
though I have already declared them in the inheritted class.

Doesn't VS traverse the inherited list or are these ignored and only used at
compilation?

VS doesn't traverse anything. Its model is much simpler: if you put the
control on the .aspx page, then a protected reference to that control will
be placed on the .aspx.cs page. Period.

Depending on the complexity of your code, you might want to define a class
which encapsulates all the common processing done on the tables, and which
perhaps contains a public property which you can set to be a reference to
the table. Then that class will have all the local variables.

Besides, even if the inheritance worked, you wouldn't really want to have
common base pages for something like this. Since there's only single
inheritance, you want to inherit from something important - you don't want
to have a base class called "PagesWithThisSortOfTableOnThem"!
 
Back
Top