View Full Version : Click Behavior Different from ASP Button and Coolite Button

Oct 30, 2009, 1:19 PM
Hello everyone,

I have been trying to add a click event to a Coolite button, and I have noticed that the behavior of the button is different from the behavior of an ASP button with the same click event.

ASP Button Implementation:

button1.Click += new EventHandler(btnClick_Click);

With this, the server side code executes normally. It updates the viewstate, and it then executes the ShowGeneralStep as expected.

public void btnClick_Click(object sender, EventArgs e)
activeViewIndex = 0;
ViewState.Add("ACTIVEVIEWINDEX", activeViewIndex);

If I use a Coolite button through, and I add the event using either AjaxEvents or Listeners, it does not execute the code as expected. It runs through the btnClick_Click method, but when the page reloads, the activeViewIndex and ViewState have not been changed. I also tried this with a Coolite button..

button1.Click += new EventHandler(btnClick_Click);

And it didn't do anything. It didn't even try to call btnClick_Click.

I tried setting ViewStateMode = ViewStateMode.Include, and it hasn't made a difference. Does anyone know what I am doing wrong? I would like to use Coolite buttons instead of ASP buttons.


Oct 30, 2009, 1:41 PM

By default the Coolite button doesn't perform postback therefore Click handler is not executed. Ypu have to set AutoPostBack="true"

If you use click AjaxEvent the ViewState is not sent back to the client by default. You have to set ViewStateMode="Include" for AjaxEvent to update ViewState on the client side

Please create simple example which demonstrates the problem

Oct 30, 2009, 1:54 PM
Thank you so much!! All I needed was to add AutoPostBack = true to solve the problem.