Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default_aspx" %>

<!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">
<script type="text/javascript"  src="http://ajax.googleapis.com/ajax/libs/jQuery/1.2.6/jQuery.min.js" language="javascript"> </script>
    
    <script type="text/javascript"  language="javascript">
        $(document).ready(function () {
            $("#<%=GridView1.ClientID%> tr").
filter(":odd").css("background-color", "grey");
        });
    </script>

    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    
        <asp:GridView ID="GridView1" runat="server">
        </asp:GridView>

    </div>
    </form>
</body>
</html>


I get the error Microsoft JScript runtime error: Object expected
Posted

1 solution

Replace the follwoing line...
HTML
<script type="text/javascript"  src="http://ajax.googleapis.com/ajax/libs/jQuery/1.2.6/jQuery.min.js" language="javascript"> </script>

with...
HTML
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" language="javascript"> </script>

Capital Q was creating the problem. Hence the URL was wrong.
It should be Small q.
 
Share this answer
 
v3
Comments
Thomas Daniels 6-Mar-14 10:36am    
+5!
Thanks a lot ProgramFOX... :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900