Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 323
kosnkov Avatar asked Jan 20 '23 01:01

kosnkov


1 Answers

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.

like image 99
Darin Dimitrov Avatar answered Jan 26 '23 00:01

Darin Dimitrov