Posts

Showing posts from August, 2011

Placing Update Progress Control dynamically

Image
Contextual Links f you're using AJAX UpdateProgress control, you may find it difficuilt to set the best position where you should put it on the page, because user will not see it if he scrolls down (or up) from it. Here is a simple solution which will make your UpdateProgress more user-friendly, because it will set the position on the screen according to user's movement of the mouse. And you will prevent user to click on any button until the postback finishes execution.  here is the code place the below code in JavaScript SCRIPT LANGUGE=JAVASCRIPT tag, ending with appropriate closing tag     function SetProgressPosition(e)     {       var posx = 0;       var posy = 0;        if (!e) var e = window.event;        if (e.pageX ||  e.pageY)          {           posx = e.pageX;           posy = e.pageY;         }     else if (e.clientX || e.clientY)       {          posx = e.clientX + document.documentElement.scrollLeft;          posy = e.clientY + document.documen

Using CASE to transform a result set from multiple rows into a summary row

 Consider the situation where sales data is stored in a table by month. One row is stored per month with a table structure that looks like the following: CREATE TABLE prodsales   (product char(3),    mnth      smallint,    sales     money) In this table, sales amounts (sales) are stored by month (mnth) and product code (product). The mnth column stores an integer value ranging from 1 (for January) to 12 (for December). You can use the following single SQL statement to product one row per product with 12 totals, one for each month: SQL Statement will go like this SELECT product,    SUM(CASE mnth WHEN 1 THEN sales ELSE NULL END) AS jan,    SUM(CASE mnth WHEN 2 THEN sales ELSE NULL END) AS feb,    SUM(CASE mnth WHEN 3 THEN sales ELSE NULL END) AS mar,    SUM(CASE mnth WHEN 4 THEN sales ELSE NULL END) AS apr,    SUM(CASE mnth WHEN 5 THEN sales ELSE NULL END) AS may,    SUM(CASE mnth WHEN 6 THEN sales ELSE NULL END) AS jun,    SUM(CASE mnth WHEN 7 THEN sales ELSE NULL END) AS j