Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.net: can not debug this problem: Sys.ArgumentNullException: Value cannot be null. Parameter name: elements

Tags:

asp.net

This is strange, that I have this problem:

Sys.ArgumentNullException: Value cannot be null. Parameter name: elements.

This problem only happens in IE.

Details:

  • ScriptResource.axd = Line: 4868
  • Code: 0 - Char: 12

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E; AskTbBT4/5.8.0.12304) Timestamp: Tue, 25 Jan 2011 11:24:42 UTC

Message:

Sys.ArgumentNullException: Value cannot be null. Parameter name: elements Line: 4868 Char: 12 Code: 0 URI: http://asdfsdf/ScriptResource.axd?d=7NwOnZl2VMauVPybpy_0vvP2zsCf0g8YK4dd3SkNMq873HwvoDhnE7rPvjFZwFLM0&t=11e661nl.js

like image 203
olidev Avatar asked Jan 25 '11 11:01

olidev


Video Answer


2 Answers

Changing ScriptMode to Release fixed this for me.

<asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Release"></asp:ScriptManager>

like image 89
Dave Shinkle Avatar answered Sep 26 '22 02:09

Dave Shinkle


I have the same problem...

It's undeniably a combination of UpdatePanel and AjaxControlToolkit...

Edit:

Didn't see how old this question was. Maybe it's not relevant anymore... But in my case I have encountered this problem now on two occations and found two different solutions. The first occation involved update panels, a modalpopupextender and a validationsummary control. The problemw was that the validationsummary didn't output a semicolon at the end of the generated javascript. The solution is to create your own mini-control that inherits from ValidationSummary and does this on pre-render:

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), this.ClientID, ";", true);
    }

Simply adds a semicolon to the javascript. That solved it.

I'm unsure if I was facing the same problem again now, but my problem-page again had updatepanels, ajaxcontrol toolkit controls (Modalpopupextender) and validaiton summaries. Because I had forgotten my previous solution, I tried another one I found on google; setting

ScriptMode="Release"

on my scriptmanager in my master page. This worked. Not sure whether I should be happy or not with this... Seems like the debug version spits out javascript that doesn't work when combined with some other asp.net controls.

like image 22
UmaN Avatar answered Sep 24 '22 02:09

UmaN