【问题标题】:asp:ImageButton OnClick event not firing in IEasp:ImageButton OnClick 事件未在 IE 中触发
【发布时间】:2014-11-29 04:42:16
【问题描述】:

我在<asp:GridView> 中使用<asp:ImageButton>,如下所示。

问题:

这在 Chrome 和 FireFox 中运行良好,但在我使用 Internet Explorer 时没有触发事件。
.aspx 代码

<asp:GridView ID="gvPatAppointment" EmptyDataText="No Data Found" runat="server"
     AutoGenerateColumns="false" DataKeyNames="capp_uniq_id"                                    
      OnRowDataBound="gvPatAppointment_RowDataBound" >
     <Columns>
         <asp:TemplateField HeaderStyle-CssClass="gridHeader" HeaderText="Cancel">
              <ItemTemplate>
                <asp:ImageButton BorderStyle="None" ToolTip="Cancel Appointment" ID="ImgCancel" 
                     runat="server" ImageUrl="~/App_Themes/NewTheme/images/CssImages/delete-file-icon.png" 
                     CommandArgument='<%# Eval("capp_uniq_id") %>'
                      OnClick="ImgCancel_Click"/>
              </ItemTemplate>
         </asp:TemplateField>
      </Columns>
</asp:GridView>

.aspx.cs 代码

protected void ImgCancel_Click(object sender, EventArgs e)
{
    lblMessage.Text = string.Empty;
    mdpCancelAppt.Show();
    SelectedAppointment = string.Empty;
    ImageButton ImgCancel = (ImageButton)sender;
    SelectedAppointment = Convert.ToString(ImgCancel.CommandArgument.ToString());`

}

【问题讨论】:

  • 请为您分享 OnClick 事件的来源
  • IE 是否在控制台中记录任何消息?
  • 您的代码中似乎有一些 javascript 错误。
  • @AntarrByrd - 是的,它显示了消息 "SCRIPT5022: Sys.WebForms.PageRequestManagerServerErrorException: Input string was not in a correct format. "
  • 好的,谢谢...我认为这个问题是 IE 特有的,没有特别的解决方案 - 所以我将使用 代替

标签: c# asp.net internet-explorer gridview


【解决方案1】:

根据你的错误提示

发生这种情况是因为您的提交按钮是带有type="image" 的input(因为它呈现为输入类型='图像')。因此,坐标与表单一起提交。以前版本的 Internet Explorer 将这些坐标以整数形式提交,但 Internet Explorer 10 以小数形式提交。

有多种方法可以修复它。有关一些解决方案,请参阅 this question 和 this bug report。

编辑 1

类似问题

  1. Sys.WebForms.PageRequestManagerServerErrorException: Input string was not in a correct format
  2. SCRIPT5022: Sys.WebForms.PageRequestManagerServerErrorException: Input string was not in a correct format

【讨论】:

  • @Shekhar - 好的,谢谢...我认为这个问题与 IE 相关,没有特别的解决方案 - 所以我将使用 &lt;asp:LinkButton&gt; 代替 &lt;asp:imageButton&gt;
猜你喜欢
  • 2010-10-21
  • 1970-01-01
  • 1970-01-01
  • 2017-07-30
  • 2013-12-20
  • 1970-01-01
  • 2020-01-31
  • 2013-04-30
  • 2011-02-05
相关资源
最近更新 更多