The problem is:
document.getElementById('leftMenu')
is null (undefined). Apparently, you simply don't have an element with
id="leftMenu"
. Check it up and make sure you have it.
Also, this method simulates the click, which is perhaps not the best way of having the same functionality on page load and on menu (button, or whatever else) click. Isn't it much easier to develop some function which you simply call from two places: when the form is loaded and from the control's event handler? If you do such thing, you won't loose anything at all but can save yourself from some annoying redundancies.
[EDIT]
Here is the problem: what is your "ID"? In your "asp" element, you should use
ClientID
instead. Please learn about its usage:
http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientid.aspx[
^].
—SA