We help IT Professionals succeed at work.
Get Started

£'s changed to ?'s in .js file linked from .aspx page

Psyberion asked
Last Modified: 2010-04-07
Hi ASP.NET Experts,

I'm running into a very confusing issue which I have traced down to ASP.NET concerning £ characters in strings, if I do the same in HTML I don't get this problem.

I created a new ASP.NET project in VS2003 called 'JSTest' and modified the code to give the following in the html view of the JSTest.aspx file:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="JSTest.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    <meta name=vs_defaultClientScript content="JavaScript">
    <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
    <script type="text/javascript" src="./test.js" language="JavaScript"></script>
    <script language="JavaScript">
          var TestStringA = "!£$%^&*()";
          alert("TestStringA: " + TestStringA);
    <form id="Form1" method="post" runat="server">

Then I created the test.js file with the following code:

var TestStringB = "!£$%^&*()";
alert("TestStringB: " + TestStringB);

Viewing this in IE6.0 on windows XP SP2 I get a popup alert dialog with the text "TestStringB: !?$%^&*()", then the second alert dialog shows "TestStringA: !£$%^&*()". It's changing the £ sign in the string of the test.js file to a ?, but why and how do I stop this?

As I said this works as expected if I create a HTML file with the same script sections.

Can anyone shed some light on this?
Watch Question
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE