Hi All,
I wish to build a user control that performs GUI related actions on a web page.
The issue I have is that it also need to call some methods on an object that will be different from page to page. The Methods that are required are all common, but the implimentation is different. It also need to execute some methods on the page that will be different from page to page.
I have started by creating an interface for the methods that need to be implimented.
And I have created events to wire the page methods to.
This is all fine except that I am unsure of how to design the control to allow any object that impliments the interface to be acted on.
At first I created a property of the interface type. This seemed to work except that the methods that need to be called are "Shared"(I think this is right, I am c# developer on
VB project, I would say "static").
I am getting some issue with assigning the Shared 'class' to the property.
Im a bit lost here so please excuse my confusion.
I think I need to utilise Generics to allow the object to be used as a shared object.
Can anyone provide some direction for this situation.
Current state of play in pseudo is:
Interface IPageHandler
method1()
method2()
Class MyBusObject:IPageHandler
method1()
method2()
Class MyControl:
private IPageHander pageHandler
public IPageHander PageHandler{get & set pageHandler}
public event event1
Button1_OnClick()
{
pageHandler.method1()
raise event1
}
Button2_OnClick()
{
pageHandler.method2()
raise event2
}
Page
Onload
{
Control myControl = new MyControl()
myCOntrol.PageHandler = MyBusObject //This is where the issue is.
wire event1 and event2 from mycontrol
}
How is this best done?
I feel an implimentation of generics is required but I am not sure how to impliment this.
Many thanks for you time in reading this.
======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================