hi guys,
I was trying to publish a mapservice to standalone server. I can do this by right click on the server--publish-- map service.

Now i want to customize a button to do the same thing, my code is :

The code won't take effect and the Select Map window won't show,unless i left-click the server with my mouse first.
any suggestions?
thanks