Tuesday, January 20, 2009

JQuery : click event from script

It's very easy to generate 'click' event from script with JQuery

$(document).ready(function() {
            var b = "<%=clicked%>";
            if (b == "0"{
                $("#Button1").click();
            }
        });


namespace ForceClick
{
    public partial class _Default : System.Web.UI.Page
    {
       public int clicked = 0;

        protected void Page_Load(object sender, EventArgs e)
        {          
        }

        protected void Button1_OnClick(object sender, EventArgs e)
        {
            Button1.Text = "Clicked by JQuery";
            clicked = 1;                
        }
    }
}

No comments:

Post a Comment