kosnkov kosnkov -4 years ago 111
jQuery Question

visual studio 2010 jquery and ScriptManager causes an error

i've just installed new visual studio 2010, and when i create new form and add jquery avaliable and scriptmanager then firefox shows me an eror
Sys.ArgumentException: An element with id 'form1' could not be found. Parameter name: elementOrElementId

form looks like this

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>


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

Answer Source

Instead of:

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

do:

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

Also jQuery's $ function might conflict with MsAjax so make sure you read about noConflict if you are planning on using jQuery. Or even better, because you plan to use jQuery throw away MsAjax and script managers. You don't need them.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download