【问题标题】:How to send value with onclick event?如何通过 onclick 事件发送值?
【发布时间】:2009-02-01 21:21:14
【问题描述】:

我有以下按钮

   <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);
}

这不起作用!!,所以我的问题是如何从按钮控件中获取值?

【问题讨论】:

    标签: c# .net asp.net events imagebutton


    【解决方案1】:

    为此,您需要订阅 Command event 而不是 Click 事件。这用于在 ASP.NET 中关注 command pattern 时使用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-28
      • 2020-03-20
      • 2014-06-07
      • 2011-02-11
      • 1970-01-01
      • 2017-02-06
      相关资源
      最近更新 更多