The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Problem and solution: Renaming htm file to aspx may cause javascript trouble

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Roy Osherove

Posts: 1807
Nickname: royo
Registered: Sep, 2003

Roy Osherove is a .Net consultant based in Israel
Problem and solution: Renaming htm file to aspx may cause javascript trouble Posted: Dec 20, 2003 10:30 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Roy Osherove.
Original Post: Problem and solution: Renaming htm file to aspx may cause javascript trouble
Feed Title: ISerializable
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/rosherove/Rss.aspx
Feed Description: Roy Osherove's persistent thoughts
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Roy Osherove
Latest Posts From ISerializable

Advertisement

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 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. Translation: 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" %>

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

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

Topic: How Everyday Things Are Made Previous Topic   Next Topic Topic: Microsoft Circles the Wagons

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use