How to pass argument with onclick event in asp.net?
We can pass the argument to onclick serverside function using the CommandArgument attribute like below.
Asp Code
Asp Code
<asp:Button id="bid" CommandArgument="456" runat="server" OnClick="passvalue" />
serverside code (.cs)
protected void passvalue(object sender, EventArgs e)
{
LinkButton btn = (LinkButton)(sender);
String testval = btn.CommandArgument; //Returns 456
}
Post a Comment for "How to pass argument with onclick event in asp.net?"