我的組件(ASCX):System.NullReferenceException - 調用二級頁面
這部分是我的網頁的一部分,和他在一起,我打開一個新頁面(下一個代碼)。
public void LoadSeller(string name, string id)
{
this.txtSeller.Text = name;
this.hdnSellerID.Value = id;
}
我彈出(CSS):
有了這個代碼,我做了一些搜索和選擇的GridView的一個項目,這個送回到我的ascx。
protected void btnSave_Click(object sender, EventArgs e)
{
Components.BasicData basicData= new Components.BasicData();
Button save = (Button)sender;
basicData.LoadSeller("TEST", save.CommandArgument);
}
回發作品,我收到正確的數據(我檢查了我的調試)。但txt和隱藏都是空的(就像他們沒有加載),他們沒有我的彈出工作,但我需要我的彈出。
任何想法?
PS:我的視圖狀態爲UP。
調試我的整個代碼,它停在
this.txtSeller.Text =名稱;
LoadSeller的第一道防線。這表示「this.txtSeller」爲空,我不知道爲什麼。我檢查了我的.designer.cs並聲明瞭this.txtSeller。 (它也工作,如果我不是從其他頁面試圖加載)
觀測值:我想知道,也許我的代碼以某種方式破壞我的其他網頁上的負載(或像這樣)。
感謝您的幫助^^
編輯:
我的結構是這樣的:
PAGE
Control1
Control2
**Open pop up**
Control3
POP UP
Search
Gridview with buttons
在gridview的按鈕
Goes to my second code "my pop up (aspx):"
Close pop up
在我的控制2我有我的第一代碼 「我的組分(ASCX):」
字幕:控制==用戶控件
痕跡導航:
- 解決方案
- 組件(文件夾)
- BasicData。ASCX
- PopUp.aspx
- 組件(文件夾)
什麼是'Components.BasicData'?如果是UserControl,你應該用'Page.LoadControl(「BasicData.ascx」)加載它,如果你想動態添加它或者直接引用它,如果它已經在頁面上。 – 2011-04-06 20:47:46
感謝蒂姆,爲您的答案^。^我嘗試使用'Components.BasicData',在這行之前'Components.BasicData basicData = new Components.BasicData();'這並沒有工作。 – 2011-04-07 12:37:53