问题描述
我正在尝试从另一个页面访问主页上的方法.主页方法是公开".调用它时,出现错误对象引用未设置为对象的实例".从主页上可以正常使用!! :confused:
I''m trying to access a method on my mainpage from another page. The mainpage method is "public". when I call it, I get an error "object reference not set to an instance of an object." It works fine from mainpage!! :confused:
推荐答案
MainPage mainPage = new MainPage();<br />
mainPage.DoCall();<br />
如果您的主页仍作为基本页面加载到内存中,则&如果要加载任何UserControl,则还可以从实例轻松访问它.
如果这可以解决您的问题,请标记为答案",如果您正在使用其他机制从另一页面加载一页,请进行详细说明.我们会更轻松地为您提供帮助.
感谢您在CodeProject中发布.
If your mainpage is still loaded in memory as the base page & on top of it if you are loading any UserControl then you can easily access it from the instance.
If this solves your problem, please "Mark As Answer", and if you are using some other mechanism to load one page from another, please elaborate the same. It will be easier for us to help you out.
Thank you for posting in CodeProject.
这篇关于从主页访问方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!