4

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?

1 Answer 1

3

Try this :

protected void btnUpdateFacturaID_Click(Object sender, EventArgs e)
{
     Button btn = (Button)sender;
     //do whatever with 
     //btn.CommandArgument.ToString()
}

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

that made it. Thank you. (i have to wait some minutes to accept the answer, you were fast! :) )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.