2009-11-06 3 views
-1

그래서 다음과 같은 구조가 있습니다.ContentPage에서 MasterPage의 HtmlGenericControl에 액세스

Start.master (Start.master.cs)

는 방법을

DoSomething(string Text) 
{ 
    _MyHtmlControl.InnerText = Text; 
} 

을 포함하며 HtmlGenericControl는

Page.aspx (페이지 _MyHtmlControl을 ID'ed. aspx.cs)

new Start().DoSomething("Test");

이렇게하면 다음 오류가 발생합니다. 개체 참조가 개체의 인스턴스로 설정되지 않았습니다.

어떻게 작동시킬 수 있습니까? DoSomething()으로 전화를 걸면 주어진 문자열을 MasterPage에 정의 된 HtmlGenericControl에 기록합니까?

답변

1

참조 :

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.

+0

고마워, 자신에 의해 검색 할 때 당신은 어떻게 그런 유용한 사이트를 찾을 수 없을 와서? - .- " –

관련 문제