[英]button click save in session
我有兩個按鈕。 查看和按日查看。
我需要知道現在單擊哪個按鈕。
如何將其存儲在會話中/或任何其他選擇???
您不能存儲Button的內容,因為它無法序列化,但是可以存儲Button的ID:
private void LogLastButton(Button button)
{
Session["LastButtonId"] = button.ID;
}
protected void ButtonView_Click(object sender, EventArgs e)
{
this.LogLastButton((Button)sender);
}
protected void ButtonViewDayWise_Click(object sender, EventArgs e)
{
this.LogLastButton((Button)sender);
}
然后,要檢索按鈕,可以按照以下步驟進行操作:
Button lastButton = Page.Controls.Find(Session["LastButtonId"].ToString());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.