You must Sign In to post a response.
  • Category: JavaScript

    Bind method to call a function

    i AM TRYING TO CALL a function on button click event, but the function is running on page load event.

    So i have used bind method to run the function on button click event.

    My code is

    var button1 = new OpenLayers.Control.Button({title:'title1',
    displayClass: "button1Display",
    trigger: myFunction1.bind('title1')});

    function myFunction1(data1) {

    with the above code, function is called on the button click event only, but data1 is undefined.

    please tell me where i am doing mistake.
  • #767525

    If you want to run script while button click then why can't you call that function in Click event of button?

    Try below sample

    protected void btnClick(object sender, EventArgs e)
    ClientScript.RegisterStartupScript(this.GetType(), "Script",javascriptfunction, true);

    If you want to execute that function before click event then OnClientClick event of button you may call that function.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • Sign In to post your comments