How to pass argument with onclick event in asp.net?

     We can pass the argument to onclick serverside function using CommandArgument attribute like below.

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

    }

0 nhận xét:

Đăng nhận xét