Javascript 出于某种原因,jquery赢得了';不能在VB项目上运行

Javascript 出于某种原因,jquery赢得了';不能在VB项目上运行,javascript,jquery,asp.net,vb.net,Javascript,Jquery,Asp.net,Vb.net,由于某种原因,此jQuery函数在此VB项目中不起作用,但正在另一个VB项目中工作/运行 不工作 <%@ Page Title="Dealer Allocation Watchlist (Marketing)" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="05055.aspx.vb" Inherits="_05055" %> <%@ Register Src="Us

由于某种原因,此jQuery函数在此VB项目中不起作用,但正在另一个VB项目中工作/运行

不工作

<%@ Page Title="Dealer Allocation Watchlist (Marketing)" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="05055.aspx.vb" Inherits="_05055" %>

<%@ Register Src="Usercontrols/wucDatepicker.ascx" TagName="wucDatepicker" TagPrefix="uc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="_titleContent" runat="Server">
    <style type="text/css">
        .style3 {
            width: 500px;
        }

        .HeaderCSS {
            color: Snow;
            background-color: Crimson;
            font-size: medium;
            border: solid 1px salmon;
            font-weight: bold;
            cursor: pointer;
        }

        .HeaderSelectedCSS {
            color: Snow;
            background-color: OrangeRed;
            font-weight: bold;
            font-style: italic;
            cursor: pointer;
        }
    </style>
    <script src="Scripts/jquery-1.7.1.min.js"></script>
    <script type="text/javascript">
        alert('yo!');
        $(document).ready(function () {
            $('#<%=lblNoRecords.ClientID%>').css('display', 'none');

            $('#<%=txtSearch.ClientID%>').keyup(function (e) {
                $('#<%=lblNoRecords.ClientID%>').css('display', 'none');
                $("#<%=grid.ClientID%> tr:has(td)").hide();

                var iCounter = 0;
                var sSearchTerm = $('#<%=txtSearch.ClientID%>').val();

                if (sSearchTerm.length == 0) {
                    $("#<%=grid.ClientID%> tr:has(td)").show();
                    return false;
                }
                $("#<%=grid.ClientID%> tr:has(td)").children().each(function () {
                    var cellText = $(this).text().toLowerCase();
                    if (cellText.indexOf(sSearchTerm.toLowerCase()) >= 0) {
                        $(this).parent().show();
                        iCounter++;
                        return true;
                    }
                });
                if (iCounter == 0) {
                    $('#<%=lblNoRecords.ClientID%>').css('display', '');
                }
                e.preventDefault();
            });
        });
        </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="_mainContent" runat="Server">

        <table>
        <tr>
            <td colspan="2" style="text-align: left;">
                <asp:Label ID="Label1" runat="server" Text="Dealer Credit Approval Watchlist (Marketing)" Font-Bold="True" Font-Names="Verdana" Font-Size="Larger" ForeColor="White"></asp:Label>
            </td>
        </tr>
            </table>
     <asp:Panel ID="Panel3" runat="server" Height="20px">
        </asp:Panel>
        <asp:Label runat="server" ForeColor="White" Font-Names="Verdana">Search results: </asp:Label>
    <asp:TextBox ID="txtSearch" runat="server" onkeyup="search()"></asp:TextBox>
            &nbsp;
        <asp:Button ID="btnSubmit" runat="server" Text="Search" />

    <asp:Panel ID="Panel2" runat="server" Height="20px">
        </asp:Panel>
    <div>

    <asp:Label ID="Label2" Text="CLICK ON 'DEALER CODE' TO NAVIGATE TO APPROVAL INTERFACE" runat="server" Font-Names="Verdana" ForeColor="white" Font-Size="Larger"></asp:Label>
    </div>
        <asp:Panel ID="Panel1" runat="server" ScrollBars="Vertical" Height="300px" Width="90%">
<asp:GridView ID="grid" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" ShowHeaderWhenEmpty="True" ShowFooter="True" Font-Names="Verdana" Font-Size="X-Small" AllowSorting="True">
        <AlternatingRowStyle BackColor="White" />
        <EditRowStyle BackColor="#7C6F57" />
        <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" Font-Names="Verdana" Font-Size="XX-Small" />
        <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" Font-Names="Verdana" Font-Size="XX-Small" />
        <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#E3EAEB" Font-Names="Verdana" Font-Size="XX-Small" />
        <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#F8FAFA" />
        <SortedAscendingHeaderStyle BackColor="#246B61" />
        <SortedDescendingCellStyle BackColor="#D4DFE1" />
        <SortedDescendingHeaderStyle BackColor="#15524A" />
        <Columns>
            <asp:TemplateField HeaderText="Dealer Code">
                <ItemTemplate>

                    <asp:LinkButton ID="lblDealerCode" runat="server" Text='<%# Eval("DealerCode") %>' OnClick="lblEdit_Click"></asp:LinkButton>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Center" Width="10%" />
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>

            <asp:templatefield headertext="Dealer Name">
                <itemtemplate>

                    <asp:Label ID="lbldealername" runat="server" text='<%#Eval("DealerName") %>'></asp:Label>
                </itemtemplate>
                <headerstyle horizontalalign="left" width="15%" />
                <itemstyle horizontalalign="left" />
            </asp:templatefield>

            <asp:TemplateField HeaderText="VH Allocated Amount">
                <ItemTemplate>
                    <asp:Label ID="lblAmount_VH" runat="server" Text='<%# CustomCDBL(Eval("Amount_VH")).ToString("#,###,###,##0") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Right" Width="10%" />
                <ItemStyle HorizontalAlign="Right" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="MX Allocated Amount">
                <ItemTemplate>
                    <asp:Label ID="lblAmount_MX" runat="server" Text='<%# CustomCDBL(Eval("Amount_MX")).ToString("#,###,###,##0") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Right" Width="10%" />
                <ItemStyle HorizontalAlign="Right" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="OB Allocated Amount">
                <ItemTemplate>
                    <asp:Label ID="lblAmount_OB" runat="server" Text='<%# CustomCDBL(Eval("Amount_OB")).ToString("#,###,###,##0") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Right" Width="10%" />
                <ItemStyle HorizontalAlign="Right" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="SP Allocated Amount">
                <ItemTemplate>
                    <asp:Label ID="lblAmount_SP" runat="server" Text='<%# CustomCDBL(Eval("Amount_SP")).ToString("#,###,###,##0") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Right" Width="10%" />
                <ItemStyle HorizontalAlign="Right" />
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
            </asp:Panel>
    <asp:Label ID="lblNoRecords" Text="No records to display" runat="server" ForeColor="red" Font-Size="Medium" Font-Bold="true"></asp:Label>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>
    </asp:Content>
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Search GridView Data</title>
    <style type="text/css">
    body
    {
        font-family: Arial;
        font-size : 10pt;
    }
    .links
    {
        font-weight: bold;
    }
    </style>

    <script type="text/javascript" src="Scripts/jquery-1.7.1.min.js"></script>

        <script type="text/javascript" language="javascript">
        $(document).ready(function() {
            $('#<%=lblNoRecords.ClientID%>').css('display','none');

            $('#<%=txtSearch.ClientID%>').keyup(function(e)
            {
                $('#<%=lblNoRecords.ClientID%>').css('display','none');
                $("#<%=gdRows.ClientID%> tr:has(td)").hide();

                var iCounter = 0;
                var sSearchTerm = $('#<%=txtSearch.ClientID%>').val();

                if(sSearchTerm.length == 0)
                {
                  $("#<%=gdRows.ClientID%> tr:has(td)").show(); 
                  return false;
                }
                $("#<%=gdRows.ClientID%> tr:has(td)").children().each(function() 
                {
                    var cellText = $(this).text().toLowerCase();
                    if(cellText.indexOf(sSearchTerm.toLowerCase()) >= 0)
                    {    
                        $(this).parent().show();
                        iCounter++;
                        return true;
                    } 
                });
                if(iCounter == 0)
                {
                    $('#<%=lblNoRecords.ClientID%>').css('display','');
                }
                e.preventDefault();
            })
        })
        </script>

</head>
<body>
    <form id="form1" runat="server">
        <br />
        <br />
        Search Text :
        <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
        &nbsp;
        <asp:Button ID="btnSubmit" runat="server" Text="Search" />
        <br /><br />
        <input id="Button1" type="button" onclick="readySearch()" value="button" />
        <br />
        <asp:GridView ID="gdRows" runat="server" BackColor="LightGoldenrodYellow" BorderColor="Tan"
            BorderWidth="1px" CellPadding="6" Font-Names="Arial" Font-Size="Small" GridLines="None"
            ForeColor="Black" Width="36%">
            <FooterStyle BackColor="Tan" />
            <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
            <HeaderStyle BackColor="Tan" Font-Bold="True" HorizontalAlign="Left" />
            <AlternatingRowStyle BackColor="PaleGoldenrod" />
            <RowStyle HorizontalAlign="Left" />
        </asp:GridView>
        <asp:Label ID="lblNoRecords" Text="No records to display" runat="server" ForeColor="red"></asp:Label>
    </form>
</body>
</html>

.style3{
宽度:500px;
}
.校长{
颜色:雪;
背景颜色:深红色;
字号:中等;
边框:实心1条鲑鱼;
字体大小:粗体;
光标:指针;
}
.校长选举{
颜色:雪;
背景颜色:橙色;
字体大小:粗体;
字体:斜体;
光标:指针;
}
警惕(“哟!”);
$(文档).ready(函数(){
$('#').css('display','none');
$('#').keyup(函数(e){
$('#').css('display','none');
$(“#tr:has(td)”).hide();
var iCounter=0;
var sSearchTerm=$('#').val();
如果(sSearchTerm.length==0){
$(“#tr:has(td)”).show();
返回false;
}
$(“#tr:has(td)”).children().each(function(){
var cellText=$(this.text().toLowerCase();
if(cellText.indexOf(sSearchTerm.toLowerCase())>=0){
$(this.parent().show();
iCounter++;
返回true;
}
});
如果(i计数器==0){
$('#').css('display','');
}
e、 预防默认值();
});
});
搜索结果:
工作

<%@ Page Title="Dealer Allocation Watchlist (Marketing)" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="05055.aspx.vb" Inherits="_05055" %>

<%@ Register Src="Usercontrols/wucDatepicker.ascx" TagName="wucDatepicker" TagPrefix="uc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="_titleContent" runat="Server">
    <style type="text/css">
        .style3 {
            width: 500px;
        }

        .HeaderCSS {
            color: Snow;
            background-color: Crimson;
            font-size: medium;
            border: solid 1px salmon;
            font-weight: bold;
            cursor: pointer;
        }

        .HeaderSelectedCSS {
            color: Snow;
            background-color: OrangeRed;
            font-weight: bold;
            font-style: italic;
            cursor: pointer;
        }
    </style>
    <script src="Scripts/jquery-1.7.1.min.js"></script>
    <script type="text/javascript">
        alert('yo!');
        $(document).ready(function () {
            $('#<%=lblNoRecords.ClientID%>').css('display', 'none');

            $('#<%=txtSearch.ClientID%>').keyup(function (e) {
                $('#<%=lblNoRecords.ClientID%>').css('display', 'none');
                $("#<%=grid.ClientID%> tr:has(td)").hide();

                var iCounter = 0;
                var sSearchTerm = $('#<%=txtSearch.ClientID%>').val();

                if (sSearchTerm.length == 0) {
                    $("#<%=grid.ClientID%> tr:has(td)").show();
                    return false;
                }
                $("#<%=grid.ClientID%> tr:has(td)").children().each(function () {
                    var cellText = $(this).text().toLowerCase();
                    if (cellText.indexOf(sSearchTerm.toLowerCase()) >= 0) {
                        $(this).parent().show();
                        iCounter++;
                        return true;
                    }
                });
                if (iCounter == 0) {
                    $('#<%=lblNoRecords.ClientID%>').css('display', '');
                }
                e.preventDefault();
            });
        });
        </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="_mainContent" runat="Server">

        <table>
        <tr>
            <td colspan="2" style="text-align: left;">
                <asp:Label ID="Label1" runat="server" Text="Dealer Credit Approval Watchlist (Marketing)" Font-Bold="True" Font-Names="Verdana" Font-Size="Larger" ForeColor="White"></asp:Label>
            </td>
        </tr>
            </table>
     <asp:Panel ID="Panel3" runat="server" Height="20px">
        </asp:Panel>
        <asp:Label runat="server" ForeColor="White" Font-Names="Verdana">Search results: </asp:Label>
    <asp:TextBox ID="txtSearch" runat="server" onkeyup="search()"></asp:TextBox>
            &nbsp;
        <asp:Button ID="btnSubmit" runat="server" Text="Search" />

    <asp:Panel ID="Panel2" runat="server" Height="20px">
        </asp:Panel>
    <div>

    <asp:Label ID="Label2" Text="CLICK ON 'DEALER CODE' TO NAVIGATE TO APPROVAL INTERFACE" runat="server" Font-Names="Verdana" ForeColor="white" Font-Size="Larger"></asp:Label>
    </div>
        <asp:Panel ID="Panel1" runat="server" ScrollBars="Vertical" Height="300px" Width="90%">
<asp:GridView ID="grid" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" ShowHeaderWhenEmpty="True" ShowFooter="True" Font-Names="Verdana" Font-Size="X-Small" AllowSorting="True">
        <AlternatingRowStyle BackColor="White" />
        <EditRowStyle BackColor="#7C6F57" />
        <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" Font-Names="Verdana" Font-Size="XX-Small" />
        <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" Font-Names="Verdana" Font-Size="XX-Small" />
        <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#E3EAEB" Font-Names="Verdana" Font-Size="XX-Small" />
        <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#F8FAFA" />
        <SortedAscendingHeaderStyle BackColor="#246B61" />
        <SortedDescendingCellStyle BackColor="#D4DFE1" />
        <SortedDescendingHeaderStyle BackColor="#15524A" />
        <Columns>
            <asp:TemplateField HeaderText="Dealer Code">
                <ItemTemplate>

                    <asp:LinkButton ID="lblDealerCode" runat="server" Text='<%# Eval("DealerCode") %>' OnClick="lblEdit_Click"></asp:LinkButton>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Center" Width="10%" />
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>

            <asp:templatefield headertext="Dealer Name">
                <itemtemplate>

                    <asp:Label ID="lbldealername" runat="server" text='<%#Eval("DealerName") %>'></asp:Label>
                </itemtemplate>
                <headerstyle horizontalalign="left" width="15%" />
                <itemstyle horizontalalign="left" />
            </asp:templatefield>

            <asp:TemplateField HeaderText="VH Allocated Amount">
                <ItemTemplate>
                    <asp:Label ID="lblAmount_VH" runat="server" Text='<%# CustomCDBL(Eval("Amount_VH")).ToString("#,###,###,##0") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Right" Width="10%" />
                <ItemStyle HorizontalAlign="Right" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="MX Allocated Amount">
                <ItemTemplate>
                    <asp:Label ID="lblAmount_MX" runat="server" Text='<%# CustomCDBL(Eval("Amount_MX")).ToString("#,###,###,##0") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Right" Width="10%" />
                <ItemStyle HorizontalAlign="Right" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="OB Allocated Amount">
                <ItemTemplate>
                    <asp:Label ID="lblAmount_OB" runat="server" Text='<%# CustomCDBL(Eval("Amount_OB")).ToString("#,###,###,##0") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Right" Width="10%" />
                <ItemStyle HorizontalAlign="Right" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="SP Allocated Amount">
                <ItemTemplate>
                    <asp:Label ID="lblAmount_SP" runat="server" Text='<%# CustomCDBL(Eval("Amount_SP")).ToString("#,###,###,##0") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Right" Width="10%" />
                <ItemStyle HorizontalAlign="Right" />
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
            </asp:Panel>
    <asp:Label ID="lblNoRecords" Text="No records to display" runat="server" ForeColor="red" Font-Size="Medium" Font-Bold="true"></asp:Label>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>
    </asp:Content>
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Search GridView Data</title>
    <style type="text/css">
    body
    {
        font-family: Arial;
        font-size : 10pt;
    }
    .links
    {
        font-weight: bold;
    }
    </style>

    <script type="text/javascript" src="Scripts/jquery-1.7.1.min.js"></script>

        <script type="text/javascript" language="javascript">
        $(document).ready(function() {
            $('#<%=lblNoRecords.ClientID%>').css('display','none');

            $('#<%=txtSearch.ClientID%>').keyup(function(e)
            {
                $('#<%=lblNoRecords.ClientID%>').css('display','none');
                $("#<%=gdRows.ClientID%> tr:has(td)").hide();

                var iCounter = 0;
                var sSearchTerm = $('#<%=txtSearch.ClientID%>').val();

                if(sSearchTerm.length == 0)
                {
                  $("#<%=gdRows.ClientID%> tr:has(td)").show(); 
                  return false;
                }
                $("#<%=gdRows.ClientID%> tr:has(td)").children().each(function() 
                {
                    var cellText = $(this).text().toLowerCase();
                    if(cellText.indexOf(sSearchTerm.toLowerCase()) >= 0)
                    {    
                        $(this).parent().show();
                        iCounter++;
                        return true;
                    } 
                });
                if(iCounter == 0)
                {
                    $('#<%=lblNoRecords.ClientID%>').css('display','');
                }
                e.preventDefault();
            })
        })
        </script>

</head>
<body>
    <form id="form1" runat="server">
        <br />
        <br />
        Search Text :
        <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
        &nbsp;
        <asp:Button ID="btnSubmit" runat="server" Text="Search" />
        <br /><br />
        <input id="Button1" type="button" onclick="readySearch()" value="button" />
        <br />
        <asp:GridView ID="gdRows" runat="server" BackColor="LightGoldenrodYellow" BorderColor="Tan"
            BorderWidth="1px" CellPadding="6" Font-Names="Arial" Font-Size="Small" GridLines="None"
            ForeColor="Black" Width="36%">
            <FooterStyle BackColor="Tan" />
            <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
            <HeaderStyle BackColor="Tan" Font-Bold="True" HorizontalAlign="Left" />
            <AlternatingRowStyle BackColor="PaleGoldenrod" />
            <RowStyle HorizontalAlign="Left" />
        </asp:GridView>
        <asp:Label ID="lblNoRecords" Text="No records to display" runat="server" ForeColor="red"></asp:Label>
    </form>
</body>
</html>

搜索GridView数据
身体
{
字体系列:Arial;
字号:10pt;
}
.链接
{
字体大小:粗体;
}
$(文档).ready(函数(){
$('#').css('display','none');
$('#').keyup(函数(e)
{
$('#').css('display','none');
$(“#tr:has(td)”).hide();
var iCounter=0;
var sSearchTerm=$('#').val();
如果(sSearchTerm.length==0)
{
$(“#tr:has(td)”).show();
返回false;
}
$(“#tr:has(td)”).children().each(function())
{
var cellText=$(this.text().toLowerCase();
if(cellText.indexOf(sSearchTerm.toLowerCase())>=0)
{    
$(this.parent().show();
iCounter++;
返回true;
} 
});
如果(i计数器==0)
{
$('#').css('display','');
}
e、 预防默认值();
})
})


搜索文本:



我不知道为什么。请帮忙。而且,当我只是简单地显示一个警告框时,它就像一个符咒。我不知道这里出了什么问题,因为该函数在另一个项目中工作。

这太愚蠢了。我将脚本放在了错误的内容夹中。

工作的javascript函数是
onclick=“readySearch()”

不起作用的标记是
onkeyup=“search()”


错误是javascript函数
search()
不存在。它不存在或拼写错误,或者应该是
readySearch()

请定义“不工作”。控制台说什么?@Teemu这是控制台说的
05055。aspx:285未捕获引用错误:搜索未在HTMLInputElement上定义。onkeyup
我已删除onkeyup上的函数绑定,现在控制台为空。