Calling a sever side code behind sub routine from client side java script


is it possible to call a server side sub routine from client side javascript
what I what to do is call a form based email routine from the client, I am hoping that by doing it this way I can disable the button used to call the routine imeadiatly so it's only possible to click it 1 time to prevent the same email being send multiple times, and in addtion start a client routine to indicate the email is underway with some graphic of some sort so the use knows that something is happening, all this is because if the attacment is quite large it takes a little while for the procees to complete making it appear that nothing much is happening
so to sum up can I call Call subSendEmail() in a code behind form for javascript on the client
If I can could some1 give me a code sample please

1/12/2005 9:46:39 PM
📃 24353 articles.

💬 1 Replies

You can't call from server-side to client-side and vice-versa.  But, you can drop client-side code and trigger server-side events to provide similar functionality.

To keep the click from being firable twice and show a progress indicator add a client-side handler:
onclick="this.disabled=true;'<Animated gif popup URL>','ProgressWindow');"
Keep the same server-side handler to do the email and when you render the page after the postback do:
Page.RegisterStartupScriptBlock("ProgressClose","<script language='javascript'>var'','ProgressWindow'); winRef.close();</script>");
1/13/2005 12:31:24 PM