Wednesday, September 16, 2009

Set conditional event handling of Control

static bool ClickStatus = false;
protected void Page_Load(object sender, EventArgs e)
{
if (ClickStatus == false)
btn.Click += new EventHandler(btn_Click);
else
btn.Click += new EventHandler(btn_Click1);
}


protected void btn_Click(object sender, EventArgs e)
{
Response.Write("
hello with deligate one");
ClickStatus = true;
}
protected void btn_Click1(object sender, EventArgs e)
{
Response.Write("
hello with deligate two");
ClickStatus = false;
}

No comments:

Post a Comment