如何将值传递到c#中的图像按钮单击事件?

尝试将一些值传递给图像按钮单击事件,如下所示:

 

然后在代码背后:

  protected void ImageButton_Click(object sender, ImageClickEventArgs e, string value1, string value2) { Response.Write(Value2); } 

尝试使用OnCommand而不是OnClick

然后,您可以在CommandNameCommandArgument属性中指定值

  

 protected void blah_Command(object sender, CommandEventArgs e) { string val1 = e.CommandName.ToString(); string [] othervals = e.CommandArgument.ToString().Split(','); }