Reputation: 771
I've been trying to pass parameters through the onclick event using asp as follows:
<asp:Button runat="server" ID="btnUpdateFacturaID" style="display:none;" onclick="btnUpdateFacturaID_Click" CommandArgument="test" />
And on the other side:
protected void btnUpdateFacturaID_Click(object sender, CommandEventArgs e)
{
string s = e.CommandArgument.ToString();
}
But I receive an error of no overload for 'btnUpdateFacturaID_Click' mathes delegate 'System.EventHandler'
In fact, I had initially the functions as follows:
protected void btnUpdateFacturaID_Click(object sender, EventArgs e)
{
string s = e.CommandArgument.ToString();
}
But this way I can't (or I don't actually know, which is much more probable) pass parameters through the event. What amb I missing?
Upvotes: 4
Views: 3553
Reputation: 148524
Try this :
protected void btnUpdateFacturaID_Click(Object sender, EventArgs e)
{
Button btn = (Button)sender;
//do whatever with
//btn.CommandArgument.ToString()
}
Upvotes: 3