You can create a base class from Page object and inherit all other pages from it. Create a method in base class and it will be accessible from all inherited pages.
e.g. ((MyBasePage)this.Page).SaveData();
>I would like my control to call the SaveData() method of any page it is dropped into. Is there a way to do that?
>
>>It's the page whose method you are trying to call from user control.
>>
>>>What does CustomerPage refer to? In my case I can't refer to any particular page, since the toolbar could be dropped into any page in the project.
>>>
>>>>You need to cast the Page with proper Page class.
>>>>
>>>>For example,
>>>>
>>>>
>>>>((CustomerPage)this.Page).SaveData();
>>>>
>>>>
>>>>You should start getting intellisense right after "Page)"...
>>>>
>>>>If that doesn't work, try this.
>>>>
>>>>
>>>> CustomerPage loCustomerPage = (CustomerPage) (this.Page)
>>>> loCustomerPage.SaveData()
>>>>
>>>>
>>>>>In the click even of one of the buttons on the usercontrol, I have the code
>>>>>
>>>>>
>>>>>this.Page.SaveData();
>>>>>
>>>>>
>>>>>When I compile, I get "'System.Web.UI.Page' does not contain a definition for 'SaveData'"
>>>>>
>>>>>>Usercontrols have a property called "Page" which is a reference to the page object that contains the instance of the usercontrol. Use this property to run any methods of the page.
>>>>>>
>>>>>>>I have a usercontrol of buttons that I use as a toolbar for pages. How do I reference a method of the page (that the control is dropped onto) from the click event of one of the buttons.
>>>>>>>
>>>>>>>For instance from the Save button, I want to call the SaveData() method of whatever page the control is on.
- Jayesh