asp:ImageButton不触发onclick事件 [英] asp:ImageButton not firing onclick event

查看:117
本文介绍了asp:ImageButton不触发onclick事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用母版页,几个RequiredFieldValidators和Web Toolkit自动完成扩展程序的页面.以下代码仅显示页面的最低要求:

I have a page that uses a master page, several RequiredFieldValidators, and the Web Toolkit autocomplete extender. The following code only shows the bare minimum of the page:

<%@ Page Language="C#" 
    AutoEventWireup="true"  
    CodeFile="Login.aspx.cs" 
    MasterPageFile="~/master.master" 
    Inherits="Login" %>

<asp:Content id="Content1" 
    contentplaceholderid="ContentPlaceHolder1" 
    runat="server">
    <asp:UpdatePanel ID="pnlUpdate" runat="server">
        <ContentTemplate>
            <div>
                <asp:ImageButton class="submitButton" 
                    imageurl="images/button_submit.gif" 
                    id="btnSubmit" 
                    runat="server" 
                    onclick="btnSubmit_ServerClick"/>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

隐藏代码:

protected void btnSubmit_ServerClick
      (object sender, ImageClickEventArgs e)
{
    //breakpoint here does not get hit
}

<form runat="server">标记在母版页中.上面的代码不会触发onclick事件.如果我摆脱了母版页,并在该页上添加了一个表单标签,则它可以正常工作.是母版页中的表单标签不受支持,还是应该以某种方式工作? 替代文本http://digitalcopy.warnerbros.com/images/mainmenu.gif?provider = 00079& disc = 03403AAA-1D20-47F2-91FA-5EE632832659

The <form runat="server"> tag is in the master page. The code above does not fire the onclick event. If I get rid of the master page and add a form tag to the page, it works. Is the form tag in the master page not supported, or is this supposed to work somehow? alt text http://digitalcopy.warnerbros.com/images/mainmenu.gif?provider=00079&disc=03403AAA-1D20-47F2-91FA-5EE632832659

推荐答案

您还可以检查ImageButton是否不触发验证.如果确实将其CausesValidation属性设置为false(当然,这是有道理的).

You can also check if your ImageButton does not trigger validation. If it does set its CausesValidation property to false (of course if it makes sense).

这篇关于asp:ImageButton不触发onclick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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