Hi,
Annie wrote:
hello guys,
I have a scenario that I am confused about ...
I have a number of pages which are using a Master page ...
Then I have seperate Footer user control that can reside in master page or
could be kept
in the content pages (still not confirmed and looking for any suggestion)
The challenge is that when the user presses the Save button within the user
control
the content of the pages needs to be saved ... I am using Strongly typed
datasets
as Data layer and there Business Objects in the middle of the pages and the
Data Layer
The challenge is that the footer should raise the save event and save the
content of the
pages independently ... I mean each page could be bound to a different
Business Object
and obviously its own Data Layer.
What is the best way to do it in this way?
Any suggestion will be appreciated?
Is there any example code available?
TA
With a situation like this, where an object (the footer) needs to send
an order to a different object (the page) without knowing exactly how
the order is going to be executed, you need a basic contract between
these two objects. The footer needs to know that if he sends a "Save"
order, the page is going to understand it. The footer doesn't need to
know more, because how each page saves itself is the page's responsibility.
The best way to do this in an object-oriented world is to use
interfaces. Have the Pages implement an interface specifying that there
is a "Save" method. The interface doesn't say more, it just allows the
footer control to take the page it is included in (each control has a
this.Page property) and then cast it to the corresponding ISaveable
interface. Note: You want to have that in a try/catch block in case the
footer is included in a page which cannot be saved.
Then, if the cast is successful, the footer knows for sure that there is
a "Save" method available.
In order to handle the common operations involved in a "Save" operation,
you can create a basic class for the pages. So the structure would be:
Page
|
SaveablePage
|
MyOwnPage
Additionally, MyOwnPage implements ISaveable.
The advantage of having the footer handle ISaveable objects rather that
SaveablePage objects is that this is more flexible, this is a less
strong relationship.
Does it make sense?
Greetings,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog:
http://www.galasoft-LB.ch
PhotoAlbum:
http://www.galasoft-LB.ch/pictures
Support children in Calcutta:
http://www.calcutta-espoir.ch