Debugging Javascript in Visual Studio

I got this from a colleague:

  1. Open Microsoft Internet Explorer.
  2. On the Tools menu, click Internet Options.
  3. On the Advanced tab, locate the Browsing section, and uncheck the Disable script debugging check box, and then click OK.
  4. Close Internet Explorer.
  5. In your JavasSript function add the keyword debugger . This causes VS.NET to switch to debug mode when it runs that line.
EX : –
function OnLookup()
{
debugger;
var xr = new XMLHttpRequest();

6. Run your ASP.Net application in debug mode.

Regular expressions for validating currency

Embedded as I am in globalizing applications I thought I would create this entry for future reference.

More than once I have to validate user input and more than once that input is a currency value. The currency symbols are not part of the expressions here.

For en-US or en-CA:

^(\d{1,3})(,\d{3})*(\.\d{2})?$

fr-CA currency formatting regular expression:

^(\d{1,3})(\s{1}\d{3})*(,\d{2})?$

Ttyl!

The mysterious get_aspx_ver.aspx page in Visual Studio 2003

I am currently working on a VS 2003 solution using VB.NET. Each time one of the team members loaded the web project our exception handling block would log a weird exception: the page requested get_aspx_ver.aspx. The exception tried to load our default error page and emailed us the proper notification.
Weird… we are not executing any code when loading the project… wrong, this mysterious page is called…

Visual Studio .NET 2003 makes an http request to the non existent web page: http://yourserver/yourweb/get_aspx_ver.aspx in order to determine the ASP.NET version installed on your web server (this information is returned in the http headers for the request). Since the page does not exist on your web server, your error handler is called.

One possible work around is to have your error handler ignore failures to this page, which is exactly what we did.

Related problems are described here:
http://support.microsoft.com/default.aspx?scid=kb;en-us;825792

and on this post in aspnetresources.com.

TTYL!

Localization Management Toolkit (beta)

A colleague and I wrote an article describing a toolkit we developed. This toolkit automates the management process of resources for localization with .NET 2.0. The article made it to the home page in DevX as featured article.
The permalink is here
http://www.devx.com/dotnet/Article/33422
We are both eager to know if someone is using a similar tool or plans to use this Toolkit.
Thanks!

More on Oracle Client and the different providers for .NET

Remember next time you write a web service or DAL class that connects to an Oracle database. If using the version 1.1 of the Framework and the Microsoft Oracle Provider, this provider has a known bug when the service name is longer than 16 characters:

The exception that you will get when trying to open the connection is:
ORA-00162: external dbid length xx is greater than maximum (16)

more on the topic can be found here

The workarounds are:
1) putting the whole tnsnames.ora entry in the DataSource entry of your connection string or
2) use Oracle’s data provider (ODP.NET)
or
3) set the TNSADMIN environment variable to point to a different directory
where you keep a modified tnsnames.ora file.

more on the troubles with the Oracle Native Provider for .NET (ODP.NET) whenever i have a chance to write again…

ECMAScript does not speak Deutsch

Did you ever have to use regular expressions on your client side code (JavaScript) to validate user input?
The .NET Framework has really cool RegularExpressionValidators that will do the job for you, however, these controls are not multilingual and this is due to the fact that ECMAScript, javascript, lacks of a specification for Unicode support.
Your common “\w” or “a-zA-Z” regular expression, while in the code behind does include Latin Extended characters such as ñ or ü, it only includes ASCII characters while used with JavaScript.

A workaround? modify your regular expressions in your javascript validators to explicitly include the characters you want.

A good post about this can be found on this blog

TTYL…

Wanna work for Google? Better get a Ph.D

Got this article extract in an email from a friend, I lost the original link though…

If you want a job at a company like Microsoft, Yahoo!, Apple, or Amazon.com, they’re going to have high standards. It doesn’t matter if you “know how to program”. They’re going to test you on algorithmic complexity analysis, advanced data structures, algorithm design, searching and sorting, internationalization techniques, network protocols, OS-level memory management, parsing and semantic analysis, recursion and mathematical induction, graph theory, combinatorics, programming language theory, machine architecture, discrete math and logic, graphics and window systems, fonts and typesetting, color spaces and representations, databases and query languages, filesystems and storage, embedded systems, device drivers, mobile and wireless protocols, and internet standards and technologies.

If you’re lucky, that is.

If you’re unlucky, they’ll ask you to derive the outline of their Ph.D. thesis on fault-tolerant massively parallel machine-learning systems. Or to solve a grand-unification style computation problem involving telephone switches, grid networks, and third-degree differential equations. Or, God forbid, they’ll ask you about the darkest corners of C++ syntax.

And you want to know why they’ll ask you about that stuff? Because they’re using it every day. They’ve tried hiring people who don’t know this stuff. Believe me, they try all the time. They want to hire more programmers, and they’re out there on the constant lookout for new meat. But when they lower their standards, they get burned. The 747 crashes, the patient dies, the juggler drops a bowling pin on someone’s head, the tiger rips someone’s throat out. In the software world: the service goes down for days, losing them millions; the project gets delivered late or even not at all, losing them contracts and customers; they lose the business battle to competitors who hired better engineers.

Excel buffer misbehaving when exporting data from SQL Server…

Ok, I’m bored tonight waiting for a release and thought I would again remind myself what to do when SQL Server 2000 refuses to write data longer than 256 characters in an excel spreadsheet. This seems to be a Jet 3.5 and 4.0 bug and the work around is published here…

http://support.microsoft.com/kb/281517

So, next time get your hands dirty and edit the registry or your data will be cut off at the 255 character when exporting from SQL Server into .xls format or when saving from .xls format into .csv.

Simple recipe for eliminating duplicates

I’ve used this code over and over, so I better save it for future ocassions.
Problem: A table (MyTable) with a field (name) I need to eliminate records with duplicated name values.

declare @name_unique varchar(50)
declare @tablename table (name_final varchar(50), value text) —every other field in MyTable

DECLARE cursor_uniquename CURSOR
FOR select distinct name from MyTable

OPEN cursor_uniquename

FETCH NEXT FROM cursor_uniquename
INTO @name_unique

WHILE @@FETCH_STATUS = 0
BEGIN

insert into @tablename select top 1 name,value from MyTable where name=@name_unique

FETCH NEXT FROM cursor_uniquename
INTO @name_unique
END

CLOSE cursor_uniquename
DEALLOCATE cursor_uniquename

truncate MyTable

insert into MyTable select * from @tablename

I wonder if there is a more efficient way, hrmmm…