Tuesday, February 4, 2014

How to fire button click event on page load in asp.net automatically


1. you can directly call your button click event like this.
    //btnSubmit is my asp.net button control's id
    btnSubmit_Click(btnSubmit,null);

2. or using jquery like this..
$(document).ready(function(){
   //Id of your button control either it is server  control or simple html control
   $("[id*='btnSubmit']").click();
});


3. if you want to call your button click event in your page load you can directly call like
protected void Page_Load(object sender, EventArgs e)
{
    //btnSubmit is my asp.net button control's id
    //It will fire each and every time your page load event is fire.
    btnSubmit_Click(btnSubmit,null);
}

No comments:

Post a Comment