Call a function on Button OnClick

Total Post:108


 1505  View(s)
Rate this:

is there a way to call a function in using c# from code behind when a button is clicked.

Button btnRemove = new Button();

btnremove.OnClientclick = Remove(ID) something like that??

I want to call a function

public void Remove(int ID)



Thank you in advance!!

  1. Re: Call a function on Button OnClick

    Hi John,

    If you want call server method you can use OnClick

    Button1.Click += new EventHandler(this.Button1_Click);
    void Button1_Click (object sender, EventArgs e)
        var control = (Button)sender;
    But you can also override your Click delegate
    protected override void OnClick(EventArgs e)

      Modified On Apr-05-2018 04:37:00 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.