A reminder to myself and others, when you want to get access to your Session State from an ASHX or HttpHandler, you need to implement IReadOnlySessionState:
<% @ webhandler language="C#" class="DownloadHandler" %>
using System;
using System.Web;
using System.Web.SessionState;
public class DownloadHandler : IHttpHandler, IReadOnlySessionState
{
public bool IsReusable { get { return true; } }
public void ProcessRequest(HttpContext ctx)
{
ctx.Response.Write(ctx.Session["fred"]);
}
}
Friday, November 6, 2009
Sunday, March 22, 2009
History of JavaScript :
JavaScript was originally developed by Brendan Eich of Netscape under the name Mocha, which was later renamed to LiveScript, and finally to JavaScript. The change of name from LiveScript to JavaScript roughly coincided with Netscape adding support for Java technology in its Netscape Navigator web browser. JavaScript was first introduced and deployed in the Netscape browser version 2.0B3 in December 1995. The naming has caused confusion, giving the impression that the language is a spin-off of Java, and it has been characterized by many as a marketing ploy by Netscape to give JavaScript the cachet of what was then the hot new web-programming language.
Due to the widespread success of JavaScript as a client-side scripting language for web pages, Microsoft developed a compatible dialect of the language, naming it JScript to avoid trademark issues. JScript added new date methods to fix the non-Y2K-friendly methods in JavaScript, which were based on java.util.Date. JScript was included in Internet Explorer 3.0, released in August 1996. The dialects are perceived to be so similar that the terms "JavaScript" and "JScript" are often used interchangeably. Microsoft, however, notes dozens of ways in which JScript is not ECMA compliant.
Netscape submitted JavaScript to Ecma International for standardization resulting in the standardized version named ECMAScript.
The flexibility of JavaScript has made it one of the most popular programming languages on the web and also one of the easier languages to learn. Initially, however, many professional programmers denigrated the language because its target audience was web authors and other such "amateurs", among other reasons. The advent of AJAX returned JavaScript to the spotlight and brought more professional programming attention. The result was a proliferation of comprehensive frameworks and libraries, improved JavaScript programming practices, and increased usage of JavaScript outside of the web.
Friday, November 21, 2008
What is the DOM?
The Document Object Model is an API for HTML and XML documents. It provides a structural representation of the document, enabling you to modify its content and visual presentation. Essentially, it connects web pages to scripts or programming languages.
All of the properties, methods, and events available to the web developer for manipulating and creating web pages are organized into objects (e.g., the document object that represents the document itself, the table object that represents a HTML table elements, and so forth). Those objects are accessible via scripting languages in most recent web browsers.
The DOM is most often used in conjunction with JavaScript. That is, the code is written in JavaScript, but it uses the DOM to access the web page and its elements. However, the DOM was designed to be independent of any particular programming language, making the structural representation of the document available from a single, consistent API. Implementations of the DOM can be built for any language.
The World Wide Web Consortium establishes a standard for the DOM, called the W3C DOM. It should, now that the most important browsers correctly implement it, enable powerful cross-browser applications.
Wednesday, August 13, 2008
Logic puzzle: Russian Roulette:
You are tied to your chair and can't get up. Here's a gun. Here's the barrel of the gun, six chambers, all empty. Now watch me as I put two bullets in the gun. See how I put them in two adjacent chambers? I close the barrel and spin it. I put the gun to your head and pull the trigger. Click. You're still alive. Lucky you! I'm going to pull the trigger one more time. Which would you prefer, that I spin the barrel first, or that I just pull the trigger?
Database:
You can delete all rows in a table by using a Delete query.
You cannot undo the action of executing a Delete query. As a precaution, back up your data before executing a Delete query.
Wednesday, August 6, 2008
All about 'event.keyCode'
keyCode returns the "virtual-key code" from the WM_KEY* messages in the Windows API when checked in the keydown and keyup events, and the ASCII/Unicode character codes in the keypress event.
For example, the DELETE key has a hex value of 007F (127 decimal) in both Unicode and ASCII. If I inspect window.event.keyCode in the keyup event, after pressing the DELETE key, the property returns a value of 46 (decimal). The DELETE key does not generate keypress events. 46 happens to be the VKey code for a delete key on my US keyboard. (VKey codes are defined in WinUser.h.)
Likewise, the keyCode also returns 65 in the keydown and keyup events regardless of whether the character entered is an "A" or an "a". However, the keyCode actually does return a 97 for "a" and 65 for "A" in the keypress event. So beware the internal inconsistency of keyCode, depending on during which event it is inspected.
Press any key here to know Keycode: