views:

31

answers:

1

i have two buttons . view and viewdaywise.

i need to know which button is clicked right now.

how to store that in session / or any other choice???

+1  A: 

You cannot store the Button as it's non-serializable, however you can store the ID of button:

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);
}

Then to retrieve the button, you can do something along the lines of the following:

Button lastButton = Page.Controls.Find(Session["LastButtonId"].ToString());
GenericTypeTea
I would use ViewState instead Session.
bloparod