handling server clicks after client side script runs

K

KK

Hi

I have an HtmlInputImage.

at the client, for onClick there is a javascript.

I want the button to be posted as well so that I can handle
the event in the server as well (In case Javascript is disabled or not
supported)

What I currently do is

MyControl : WebControl,IPostBackDataHandler,INamingContainer,
IPostBackEventHandler{

onInit(){
controlButton.ServerClick+=new
ImageClickEventHandler(controlButton_ServerClick);
Page.RegisterRequiresPostBack(this);
Page.RegisterRequiresRaiseEvent(this);

}

private void controlButton_ServerClick(object sender, ImageClickEventArgs
e)
{
Debug.WriteLine("server click");
}

public void RaisePostBackEvent(string eventArgument)
{
controlButton_ServerClick(this,null);
}
}

This way, when the client clicks the image, javascript handles it at client
side and
I am able to call the controlButton_ServerClick() server side function
within
the RaisePostBackEvent().

But I think I am doing something wrong. Shouldn't the Page framework be
calling my serverclick event?? (without me having to call the buttons click
event
explicitly?)

thanks
KK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top