JavaScript code runs on the old server, but not on the new

It drove me crazy. I'm trying to port some outdated applications to a new server, and I had a lot of problems with document.allstuffed all over the code.

Before you say that, I know. Do not use document.all. There is nothing I can do about it there ... this particular problem has JavaScript in the assembly, for which I do not have source code, and I do not have permission to reprogram it.

My main perplexity is that the current version of the application works when I test in the same browser as my ported version. This is a direct copy and paste of the task, and during the migration the code has not changed, but when you start the application on a new server it document.all(element)always returns null.

Are IIS or newer .NET structures somehow handling client scripts differently?

I am going from .NET 2.0 hosted on Windows Server 2005 with IIS 6 and will migrate to .NET 4.0 hosted on Windows Server 2012 with IIS 8.

I am looking for ANY idea why they will behave differently when tested in the same browser

UPDATE: The user control that it is targeting document.allreceives an encoding that enters the identifier of the control, i.e. What should be 'elementId'output as'elementId'

The assembly uses the Attributes.Add code, which includes single quotes. I found several sources offering a new class, for example:

public class HtmlAttributeEncodingNot : System.Web.Util.HttpEncoder
{
    protected override void HtmlAttributeEncode(string value, System.IO.TextWriter output)
    {
        output.Write(value);
    }
}

which will disable coding using <httpRuntime encoderType="HtmlAttributeEncodingNot"/>in web.config, but I can’t add new classes to this project

+3
2

, , . , document.all IE11, , - .

Javascript DOM , .NET 2. JS ( onload), , , document.all, .

0

, , , - .

, . :

public class HtmlAttributeEncodingNot : System.Web.Util.HttpEncoder
{
    protected override void HtmlAttributeEncode(string value, System.IO.TextWriter output)
    {
        output.Write(value);
    }
}

web.config: <httpRuntime encoderType="HtmlAttributeEncodingNot"/>

, Attributes.Add $#39;

, -, JavaScript, - , .net ClientID . , <xhtmlConformance mode="Legacy"/> clientIDMode="AutoID", html , 2.0, .

+1

All Articles