Pages

Monday, 20 February 2012

Get ID of the Dynamicaly created Button in ASP.NET

      Let the dynamically calling function be Btn_Click,then the ID of the clicked button can use as like the following;
        protected void Btn_Click(object sender,EventArgs e)
        {
                //Assign the id to the string ButtonID
               string ButtonID = ((Button)sender).ID.ToString( ) ;
               //Set ID to Label1's Text property
               Label1.Text  = ButtonID.ToString( ) ;
        }

1 comment: