0
我使用ASP.NET網站的模型視圖演示程序方法。呈現部分在單獨的類庫編譯其中視圖合同和主持人的定義:從類庫彙編中設置ASP.NET頁面控件
MyPresentation assembly
IMyView
{
DisplayText(string text);
}
MyPresenter
{
public IMyView View { get; set; }
public DisplayText()
{
string text = Generate();
View.DisplayText(text);
}
}
MyWebApplication assembly
public partial class MyForm : System.Web.UI.Page, IMyView
{
public void DisplayText(string text)
{
this.myLabel.Text = text;
}
...
protected void myButton_Click(object sender, EventArgs e)
{
Presenter.DisplayText(); // calls this.DisplayText()
}
}
然而走出的myLabel
Presenter.DisplayText()
Text屬性後,再次成爲空,就像沒有分配中進行。通過所有方法,如果您替換myButton
單擊事件中的唯一行,並直接設置myLabel
文本屬性將保持分配狀態。
否它不,我已經從主持人 –
返回一個已知字符串「但是,在退出Presenter.DisplayText()之後myLabel的Text屬性再次變爲空」 –