I am writing a web app in asp.net. I have an aspx page that call a class (Test) that Generates a button and return the button. The class constructor get the function that the button click event should activate (userClickOnButton) and insert to the button.click += EventHandler("the name of the function (userClickOnButton)");
the problem is that in the aspx behind code i use IsPostBack (cant take it off , need this Condition) and when i click on the button the progrem does not go to the event i created for the button, but when i take off the IsPostBack Condition the program does go to the event i created (the function userClickOnButton).
my code is: aspx code behind
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Test test = new Test(userClickOnButton);
Button button = test.AddButton();
cell.Controls.Add(button);
}
}
private void userClickOnButton(object sender, EventArgs e)
{
this.ModalPopupExtenderSelectFilds.Show();
}
my class
public class Test
{
Action<object, EventArgs> m_ButtonClickActivateFunction;
public Test(Action<object, EventArgs> func)
{
m_ButtonClickActivateFunction = func;
}
public Button AddButton()
{
Button button = new Button();
button.Text = "select";
button.ID = "buttonID";
button.Click += new EventHandler(m_ButtonClickActivateFunction);
return button;
}
need help to activate the event without taking out the IsPostBack Condition
thanks