How to send value with onclick event?
-
20-08-2019 - |
Question
I have the following button
<asp:ImageButton ID="button1" runat="server"
ImageUrl="~/image.jpg"
CommandName = "id"
CommandArgument = "1"
onclick="button1_Click"
/>
and in code behind
protected void button1_Click(object sender, ImageClickEventArgs e)
{
Response.Write(e.commandName);
}
this does not work!!, So my question is how to get value frombutton control?
Solution
For this to work you need to subscribe to the Command event instead of the Click event. This is used when following the command pattern in ASP.NET
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow