---
title: "Problem and solution: Renaming htm file to aspx may cause javascript trouble"
url: "https://osherove.com/blog/2003/12/20/problem-and-solution-renaming-htm-file-to-aspx-may-cause-jav.md"
canonical: "https://osherove.com/blog/2003/12/20/problem-and-solution-renaming-htm-file-to-aspx-may-cause-jav.html"
published: "2003-12-20T16:07:00"
updated: "2003-12-20T16:07:00"
tags: [".Net Original", "Tips & Tricks"]
author: "Roy Osherove"
description: "We ran across this when moving some old files to a new project. One of the tasks was to turn a very simple htm file into the same file with an aspx extension. The original htm file had a reference to a javascript file.…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Problem and solution: Renaming htm file to aspx may cause javascript trouble

By Roy Osherove December 20, 2003 In [.Net Original](https://osherove.com/blog/category/net-original), [Tips & Tricks](https://osherove.com/blog/category/tips-tricks)

**Historical article** · Originally published December 20, 2003; technical details may be outdated.

We ran across this when moving some old files to a new project. One of the tasks was to turn a very simple htm file into the same file with an aspx extension.

The original htm file had a reference to a javascript file. The trouble was that the new aspx file would not respond to the javascript events that the original htm file referenced (and worked perfectly with). The javascript in question was a calender widget that would appear on a button click on the page.

We narrowed it down to reproduce the problem with a simple 5 line htm file which worked. and a renamed version of the htm file as an aspx file which did not work. After some clues from [Mike Gunderloy](http://www.larkware.com/) I enabled script debugging on my machine and saw that we were getting an error from a specific line in the js file. The error was:

Line: 63
Error: Unterminated string constant

Looking at that line in the script reveals something strange (looking inside the debugger):

63:  es : 'Presione para seleccionar un a??

64: de : 'Klicken um Jahr auszuwählen',

so the string in line 63 was not closed because it was corrupt. There should have been a **',** there like this:

  es : 'Presione para seleccionar un año',

Looking at the direct source I could see that the text was **not** corrupt so this was coming from the browser! even more, this worked in the original htm version of the file. After some more clues from Mike it appears that the character set in the js source was not recognized using the aspx file. T**ranslation**: the aspx file was using a code page that did not include the letters at the end of the sentence in the js source file, so it thought it was corrupt and everything got screwed up.

The solution to this is pretty simple. Make the code page for the aspx file into code page 1252 by adding it in the page declaration tag:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="calTest.aspx.vb" Inherits="calTest.WebForm1" codepage="1252"%>

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="calTest.aspx.vb" Inherits="calTest.WebForm1" %><%@ Page Language="vb" AutoEventWireup="false" Codebehind="calTest.aspx.vb" Inherits="calTest.WebForm1"  **codepage="1252"** %>

Now the page can recognize the characters and all is right again in the world.

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="calTest.aspx.vb" Inherits="calTest.WebForm1" %>

## More in .Net Original

[All posts in .Net Original](https://osherove.com/blog/category/net-original)

- Dec 27, 2003

    ### [Code: CRUD base classes for unit testing](https://osherove.com/blog/2003/12/27/code-crud-base-classes-for-unit-testing.html)

- Dec 25, 2003

    ### [My First \*real\* SQL optimization (and some good resources)](https://osherove.com/blog/2003/12/25/my-first-real-sql-optimization-and-some-good-resources.html)

- Dec 19, 2003

    ### [Service announcement: Feedable and Regulator live again, and Norway tips](https://osherove.com/blog/2003/12/19/service-announcement-feedable-and-regulator-live-again-and-n.html)

- Dec 18, 2003

    ### [Homesick, EIF and a session state FAQ](https://osherove.com/blog/2003/12/18/homesick-eif-and-a-session-state-faq.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
