我有以下按钮
<asp:ImageButton ID="button1" runat="server"
ImageUrl="~/image.jpg"
CommandName = "id"
CommandArgument = "1"
onclick="button1_Click"
/>
在代码后面
protected void button1_Click(object sender, ImageClickEventArgs e)
{
Response.Write(e.commandName);
}
这不起作用!!,所以我的问题是如何从按钮控件中获取值?
最佳答案
为此,您需要订阅 Command event。而不是点击事件。这在遵循 command pattern 时使用在 ASP.NET 中
关于c# - 如何使用 onclick 事件发送值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/501603/