我有一个使用母版页、几个RequiredFieldValidators和Web Toolkit自动完成扩展器的页面。下面的代码只显示了页面的最小部分:
<%@ 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事件。如果我去掉了母版页并在页面上添加了一个表单标签,它就能工作。母版页中的表单标记是否不受支持,或者这是否应该以某种方式起作用?alt text http://digitalcopy.warnerbros.com/images/mainmenu.gif?provider=00079&disc=03403AAA-1D20-47F2-91FA-5EE632832659
发布于 2009-04-25 05:52:57
您还可以检查您的ImageButton是否未触发验证。如果确实如此,则将其CausesValidation属性设置为false (当然,如果它有意义的话)。
发布于 2009-08-25 22:56:07
我也遇到过类似的问题(不同的场景)。我使用了Page.RegisterRequiresRaiseEvent(ImageButton),我的onclick事件开始触发。我为什么要这么做?我不知道。
发布于 2013-04-10 05:03:14
我的解决方案是将ImageButton的CausesValidation设置为false。
https://stackoverflow.com/questions/788018
复制相似问题