如何通过onclick事件发送值?
我有以下按钮
<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);
}
不起作用!!,所以我的问题是如何从按钮控件获取值?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,您需要订阅 命令事件而不是单击事件。 当遵循 ASP.NET 中的命令模式时使用此选项
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