Accessing a HtmlGenericControl on a MasterPage from a ContentPage
so I've got the following structures;
Start.master (Start.master.cs)
Contains a Method
DoSomething(string Text)
{
_MyHtmlControl.InnerText = Text;
}
And the HtmlGenericControl ID'ed _MyHtmlControl
Page.aspx (Page.aspx.cs)
Calls the Method via new Start().DoSomething("Test");
Doing so gives me the following error: Object reference not set to an instance of an object.
How can I make it w开发者_如何转开发ork, so I can call DoSomething()
and it writes the given string into the HtmlGenericControl that is defined in the MasterPage?
See:
ASP.Net Master Pages: Tips, Tricks, and Traps
Abstract Interaction
Now it’s time to have the master page and content page interact. There are different approaches we can take to achieve interaction, but the best approaches are the ones that use the master page for what it is: a user control.
精彩评论