如何使用onclick事件送价值? [英] How to send value with onclick event?

查看:98
本文介绍了如何使用onclick事件送价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下按钮

   <asp:ImageButton ID="button1" runat="server" 
   ImageUrl="~/image.jpg"
   CommandName = "id"
   CommandArgument = "1"
   onclick="button1_Click"
   />

在code后面

protected void button1_Click(object sender, ImageClickEventArgs e)
{
    Response.Write(e.commandName);
}

这不工作!,所以我的问题是如何获得的价值frombutton控制?

this does not work!!, So my question is how to get value frombutton control?

推荐答案

对于这个工作,你需要订阅的命令事件而不是Click事件。以下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

这篇关于如何使用onclick事件送价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆