So on my Default.aspx page I have several listboxes which I am populating on page_load.
However, if the user changes these listboxes and wants to restore the original settings, I want a button at the top, which is defined in the Site.Master, to call this same function gain to restore the original values.
How can I obtain a reference to an instance of the _Default object from the Site.Master file? Is there a way to globally access the instance of _Default that is called when the page is first loaded? Or do I need to store that manually somewhere?
For example:
Default.aspx.cs:
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
setConfigurationData();
}
public void setConfigurationData()
{
//Do stuff to elements on Default.aspx
Site.Master.cs
namespace WebApplication1
{
public partial class SiteMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RefreshMenu1_MenuItemClick(object sender, MenuEventArgs e)
{
//Need to call this function from an instance of _Default, but I don't know
//how to retrive this or save it from when it is first created
//_Default.setConfigurationData();
Add this class scoped variable to your Master page
Then add this method to your Master page
Now in the Page_Load of your Default page add
Now your master page should be able to access the objects on the Default page through the reference in its currentContentPage variable.