Archive for the 'ASP.NET' Category

jscalendar shows at the top of the screen in IE7

jscalendar v1.0 has a bug that makes the calendar displays at the top of the screen in IE7.

Here is a patch that fixes it.

reference: http://drupal.org/node/118926

JavaScript font detector

I found this little JavaScript utility that tests for the existence of a specific font on the client machine.
I thought it would be very handy to use for my church’s website (coming soon) which will probably have some content written in the Coptic language.

Most probably we will be using Athanasuis font.

Anyways, I want to save the script here in case the original site goes down or something.

The script is released under Apache License, Version 2.0

Persisting SessionID Across Multiple Requests

Today we had a problem while working on Darden’s project.

We were using the SessionID as a unique key to store some information about the behavior of the user surfing the site.

The SessionID was getting changed with every page request.

The trivial solution was adding a global.asax file to the project.

Regex for U.S and Canadian Zip Codes

for my future references, below is a regular expression for validating U.S and Canadian zip codes.

^\d{5}(?:-\d{4})?$|^[a-zA-Z]\d[a-zA-Z]\s?\d[a-zA-Z]\d$

more details on the format of Canadian zip codes

C# Numeric Literals Suffixes

The suffixes in the table below are useful because they tell the compiler what type a numeric literal is and how it should be treated. The default type of a numeric literal is integer (int) of course, but if you want to specify decimal or long, how would you do that? (please don’t cast it, it’s ugly)

Consider having an overloaded method, one overload takes a parameter of type long, another of type int, now if you want to pass in the number ‘15′ for example, these suffixes will help you choose which overload to actually invoke by appending a letter (or two) to the numeric literal.

Type   Suffix   Example
  uint   U or u   100U
  long   L or l   100L
  ulong   UL or ul   100UL
  float   F or f   123.45F
  decimal   M or m   123.45M

Note that the suffixes are case-insensitive.

DateTime & Number Format String Cheat Sheet

I don’t know why I haven’t spent the time to create something handy like this!

If you are a .net developer (specially an asp.net one) you certainly will see the benefit of this cheat sheet. Personally I have wasted my time before trying to format an integer to print in a certain way and of course i didn’t have the correct format-specifier right off the top of my head so i had to hunt down the information on Microsoft’s slow-and-poorly-searchable msdn which is certainly something i try to avoid!

reference: Scott Gutherie’s blog

Subsonic DAL

Subsonic is my favorite library for creating data access layers in asp.net.

  • It creates properties to the related entities/tables in the database, some people like to call this feature Deep Properties!
  • no need to create CRUD stored procedures for every table in the db
  • you can do queries on the fly, WHERE clauses, ORDER BY clauses and aggregate functions
  • It’s open-source and free
  • the classes are generated using a tool, no more tedious DAL writing
  • for your convenience you get “Scaffolding forms”.
  • it uses parameterized dynamic sql, which makes all those great features above possible
  • It has providers for MS Sql Server and MySQL

If you are an asp.net developer you should give it a try, or at least check it out, it’ll be worth your while.