Home > DeveloperSection > Forums > Call a function on Button OnClick
john rob

Total Post:108

Posted on    August-28-2014 1:29 AM


 1 Reply(s)
 1009  View(s)
Rate this:

is there a way to call a function in asp.net 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!!

Sumit Kesarwani

Total Post:378

Posted on    August-28-2014 2:16 AM

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)




Don't want to miss updates? Please click the below button!

Follow MindStick