因此,在我的 Default.aspx 页面上,我在 page_load 上填充了几个列表框。
但是,如果用户更改了这些列表框并想要恢复原始设置,我希望在顶部有一个按钮(在 Site.Master 中定义)来调用相同的函数 gain 以恢复原始值。
如何从 Site.Master 文件中获取对 _Default 对象实例的引用?有没有办法全局访问第一次加载页面时调用的 _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
站点.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();