kosnkov
kosnkov

Reputation: 5911

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>

Upvotes: 4

Views: 4693

Answers (2)

cooldude
cooldude

Reputation: 1

Add EnablePartialRendering="false" to the scriptmanager

Your aspx page will have the below code

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta name="viewport" content="width=device-width" />
    <title>my Test page</title>

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

        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="false"></asp:ScriptManager>
            <rsweb:ReportViewer ID="ReportViewer1" runat="server" AsyncRendering="false" Width="100%" ShowToolBar="false">
            </rsweb:ReportViewer>
        </div>
    </form>
</body>
</html>

Upvotes: 0

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

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.

Upvotes: 9

Related Questions