15
votes

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

5
Can you show some code involving the parameter elements? The error says your elements variable is null or undefined. Show the line of code how you are getting elements?Sachin Shanbhag
Are you using any AJAX controls? Ajax Control toolkit? Third party ASP.NET AJAX controls?Brian Mains
I have the same problem. It's undeniably some combination of UpdatePanel and ajaxcontroltoolkit.UmaN

5 Answers

31
votes

Changing ScriptMode to Release fixed this for me.

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

16
votes

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.

4
votes

You will also get this error if you set Visible=False on the control specified in the CancelControlID of a ModalPopupExtender. If you have a code path where you need to hide the CancelControlID, just be sure to set the CancelControlID = "" in that situation. That was the problem I ran into...

2
votes

In Case you are using ReportViewer on the page this might help.

Set compilation debug="false" in web.config.

1
votes

Happend to me where I've created an update panel in a custom server control and did not use RenderControl() afterwards

protected override void RenderContents(HtmlTextWriter writer)
{
  myUpdatePanel.RenderControl(writer);
}