jquery没有在子aspx页面中触发

时间:2016-02-10 10:53:27

标签: javascript jquery asp.net jquery-ui webforms

我有这段代码:

<%@ Page Title="Edit Your Password" Language="C#" MasterPageFile="~/Master/Profile.master" AutoEventWireup="true" CodeBehind="Edit-Password.aspx.cs" Inherits="MyApp.Profile.Edit_Password" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        jQuery(document).ready(function () {
            jQuery(".pass2").on('keyup', function () {
                alert('test');
            });
            jQuery(".pass1").on('keyup', function () {
                alert('test1');
            });
            jQuery("#txtNewPassword").on('keyup', function () {
                alert('test2');
            });
            jQuery(".txtNewPassword").on('keyup', function () {
                alert('test2');
            });
            jQuery("#<%=txtNewPassword.ClientID %>").on('keyup', function () {
                alert('test2');
            });
        });
        jQuery(function () {
            jQuery("#<%=txtNewPassword.ClientID %>").on('keyup', function () {
                alert('test2');
            });
            jQuery(".pass2").keyup(function() {
                alert('keyup');
            });
        });
        jQuery("#<%=txtNewPassword.ClientID %>").keypress(function (e) {
            alert('test');
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ChildContent1" runat="server"> 
<section>
    <div>
        <div>
            <div>
                    <div>
                     <asp:TextBox runat="server" TextMode="Password" ValidationGroup="EditPassword" CausesValidation="True" CssClass="pass1" ID="txtNewPassword"></asp:TextBox>
                    </div>
                    <div id="confirm_password_field" class="control-group">
                        <asp:TextBox runat="server" TextMode="Password" ValidationGroup="EditPassword" CausesValidation="True" CssClass="pass2" ID="txtNewPasswordConfirm"></asp:TextBox>
                    </div>
                    <asp:Button runat="server" ID="btnSubmit" CssClass="light-blue-button" CausesValidation="True" ValidationGroup="EditPassword" Text="Save Changes" OnClick="btnSubmit_OnClick"/>
            </div>
        </div>
    </div>
</section>
</asp:Content>

我尝试了不同的方法来获取keyup事件,但是当我使用页面时没有触发它们。

知道还有什么我需要检查的吗?

由于

0 个答案:

没有答案