我一直在寫代碼在Page_Load中的功能是這樣如何防止在Asp.net頁面中添加相同的事件?
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
UserControl1.Button_Clicked += new EventHandler(UserControl1_Button_Clicked);
}
}
但是,當頁面從另一個頁面引導到這個頁面相同的功能將被再次添加。
有沒有什麼方法可以防止它發生?
我想使用會話,以防止它,但我想知道有沒有更好的方法可以做同樣的工作。 非常感謝!
你在使用Server.Transfer嗎? – jrista 2009-06-03 01:57:47