July 2009 Entries

ASP.NET MVC with jQuery Grid

Incorporating the jQuery Grid With ASP.NET MVC Scenario: You have an ASP.NET MVC application and don't want to custom build smart controls like the ASP.NET GridView, ListView, etc, that support sorting and paging, as well as filtering and searching for data, and all of this using Ajax. Solution: The jQuery Grid plug-in. What tools/plug-ins do I need? jQuery version 1.3 and up jqGrid version 3 and up (this post references version 3.4.4) A strong cup of coffee In the past you had to also add the jQuery ......

jQuery Selector efficiency/cost impact

Normal 0 false false false MicrosoftInternetExplorer4 st1\:*{behavior:url(#ieooui) } /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.000... mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} ......

Useful jQuery Plug-ins

Normal 0 false false false MicrosoftInternetExplorer4 st1\:*{behavior:url(#ieooui) } /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.000... mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} ......

jQuery in Action or Learning jQuery

Normal 0 false false false MicrosoftInternetExplorer4 st1\:*{behavior:url(#ieooui) } /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.000... mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} ......

Favorite Techical Books

A list of my favorite technical books that I found very useful over the years. Most of them are related to CSS, jQuery, DHTML, Ajax, and ASP.NET C#: <A HREF="http... _fcksavedurl=&q... ......

The Firefox prayer

Our Firefox who art my browser, hallowed by they name; they Firebug please come; they will be done, in IE as in Firefox . Give us this day our daily browser traffic. And forgive IE (especially 6 and 7) its trespasses , as we have forgiven IE8 for theirs. And lead us not into IE9; but deliver us from IE 5, 6 and 7. For thine, oh mighty Firefox is the future, the market and the surfer's playground; for ever and never. Ahem! God is good ......

How to find out what is calling a Javascript function

Scenario: What is calling a Javascript function. You may have a situation where a function in your code (or anyone else's for that matter) that is loaded into a web page is being called many times, and although in the Firebug profiler you may see the function being called 1000 times, you want to know who is responsible for calling it. The problem: You may use the console.log in Firebug to do this, or even break in the function and step out of it to see who is calling it, but this may be difficult ......

Keyboard shortcut to inspect an element in Firebug

Scenario: Inspect an element in Firebug, click the inspect button (or flashlight icon in the new version 1.4.0b5). The problem: But you want to do this with a keyboard shortcut. The solution: Ctrl+Shft+C Some concerns: With the number of extensions Firefox offers you may experience keyboard shortcut clashes, like for example with the CacheViewer which uses Crtl+Shft+C also. Firebug is a free Firefox extension. Ready to install? From several reponses received and from my own expreience since I upgraded ......

How to set Firebug profiling programmatically

Scenario: You are using the profiler tab in Firebug that profiles everything, in stead you would rather profile one specific function. The solution: You can do this programmatically inside your function: function MyFunction() { console.profile('somename'); ... console.profileEnd('somenam... } Firebug is a free Firefox extension. Ready to install ......

Dynamically setting jqGrid search

You are using the jqGrid search option but in one instance you want to enable the search but on another you want to disable the search for the same grid. The problem: This cannot be done, in short, by setting the properties dynamically, like so: gridComplete: function() { setGridParam({ gridModel: true, gridNames: false, gridToolbar: true, autosearch: false, enableClear: true, enableSearch: true, toolbar: [true, "top"] }); } Setting the search option dynamically during a loadComplete, or gridComplete, ......

jQuery Grid Plugin

Building web-apps using the new MVC-framework for ASP.NET can be challenging if you need to build the boiler-plate code for the SMART controls that come standard with ASP.NET, like the GridView, ListView, etc. However, jQuery's (see jQuery in Action for an excellent resource) plug-in, jqGrid, makes this easy. Although it can be time-consuming to setup the template that specifies the requirements for the grid, it is easy to duplicate once you have it set up. So basically you specify the columns you ......

OutputCacheAttribute Override/Customization

The scenario: A web app is using the OutputCacheAttribute to set a cache duration for data that has different life spans. The IDE: ASP.NET MVC with Visual Studio 2008 The environment: Web-App on IIS The data that is being retrieved varies greatly in terms of their lifespan: Some data is very static like States, Countries Other data is more fluid, especially during end-user testing, like the load of scripts that have to be fixed occasionally and pushed to production during the day. Especially early ......

Firebug Console Quick Reference Guide

Firebug adds a global variable named "console" to all web pages loaded in Firefox. This object contains many methods that allow you to write to the Firebug console to expose information that is flowing through your scripts. console.log(object[, object, ...]) Writes a message to the console. You may pass as many arguments as you'd like, and they will be joined together in a space-delimited line. The first argument to log may be a string containing printf-like string substitution patterns. For example: ......

Firebug Network Monitoring Quick Reference Guide

Network Monitoring Your web app on the server has plenty of tools and ways to measure performance, as well as tools like SQL-Server Profiler for SQL databases. But how do you trace, track and debug client-side code interactively? The use of alerts has been useful but does not support an interactive way for you to interact with the web-page on the fly. To make matters worse, even if you place some traces into your js code to help find the slow functions, etc, network latency may be another cause of ......

jqGrid Dynamically loading select options

Scenario: You are using the jqGrid to edit rows that contain fields that are of HTML tag type "SELECT". Problem: You do not want to hard code the values of the select tag like in the jqGrid samples. For example: editoption: { value: "FE:FedEx; IN:InTime; TN:TNT" } Solution: For example to load a list of countries dynamically, define the variable before the definition of the jqGrid: //get all countries var countries = $.ajax({url: $('#ajaxAllCountriesUrl').v... async: false, success: function(data, ......

How to stop a run-away SQL transaction

The Problem: Recently was testing my web-app against a SQL-Server 2008 database and got a time-out expired message from the SQL database. No matter what I did after that it just did not want to drop the transaction and I continually got the time-out. I needed to find and stop the SQL transaction. The solution: Sign onto the SQL-Server with the Enterprise Manager. Execute sp_who2 and look for rows that are blocked on another connection (the BlkBy column will have the spid of the blocking connection ......