Posts

Showing posts from 2012

Bit By Bit: Microsoft Destroys Decades-Old Hierarchical Scoped Settings

  Microsoft Destroys Decades-Old Hierarchical Scoped Settings For over four decades, Microsoft built its empire on a foundation of consistency, reliability, end-user trust. There is an established hierarchical configuration model that has been in place for years and adopted by the entire software industry. The scenario is simple, a machine level (top) layer of settings meant to be applied consistently to all. This developer works with several clients, each with different requirements in their application, so without disturbing the configuration of any other project, he makes the adjustments to the solution layer. Now to add complexity but certainly a common situation, one project manager in this solution has his own requirements. The developer creates another configuration file with the new requirements. This is a perfect example of a typical large-scale project, not an edge case exception. If there is a setting in the lower level (project) that exists in a higher (machine) level...

Simple JQuery image button mouse over (hover) effect

Simple JQuery Image Button Hover Effect Overview:    Here is just a quick down and dirty JQuery function to handle the MouseEnter and MouseLeave events of the target control labeled with the class "button" in this case it's an image control. As you can see below hover accepts two arguments, these arguments are then MouseEnter and Mouseleave events. By changing these arguments you can control many other elements properties and add other effects. Thats really all there is too it JQuery function:      Just drop this in your page head section and set your appropriate image paths. < script   type = "text/javascript" >         $(document).ready( function  () {                        $( ".button" ).hover( function  () {        ...

Handling backspace/delete with AJAX MaskedEditExtender in chrome

      Another one of these annoying behaviours with AJAX controls is with the Masked Edit Extender and Chrome browsers. As designed (according to Microsoft) the AJAX MaskedEditExtender does not handle the backspace or delete key strokes. I have not tested this with all mask types, but one in particular is the date mask type.       I wanted to add just a touch of control to my birthdate text control. Nothing real fancy just format "99/99/9999" to restrict the user gobbly gook. All works as advertised except that you can't use the backspace key if you make a mistake. I don't know about you all, but that key has been my friend since day one, so not being able to use it got me Goggling.  With some searching I came across this javascript that handles the key presses and enables delete in the MaskedEditExtender.     Here's the markup. Just need to add the key handlers to the textbox and put the extenders id as function arguments.  ...

Randomizing LINQ to SQL Query Results

Another stumper solved today.. Something as simple as randomizing LINQ results It's not something built-in. There is no  Random  query operator provided by Microsoft. In addition, it can't be done simply by using the  System.Random  class, because everything in a LINQ to SQL query must be translatable to SQL. That being the case... Let's detail the solution that uses a SQL user-defined function. The most common way to sort records randomly is to use the  NEWID  SQL Server function. This is what this solution uses. First, create the following view: CREATE VIEW RandomView AS SELECT NEWID() As ID Then create the following function that uses the view: CREATE FUNCTION GetNewId ( ) RETURNS uniqueidentifier AS BEGIN RETURN (SELECT ID FROM RandomView) END The view is required because it's not possible to directly use  NEWID  in a scalar function. And now we can use this in any LINQ to SQL query to retrieve truly random records. ...

Using ResolveUrl to correct paths in html controls

Just a quick post. When i'm working on my development server and debug locally I run into issues on html controls and paths.  Such as:  http://localhost:9999/YourVirtualDirectory/ The directory does not really exist so when the dom objects access paths like this, they won't work < script   type = "text/javascript"   src = "~/Scripts/jquery.lavalamp.js" ></ script > Neither will this < script   type = "text/javascript"   src = "../Scripts/jquery.lavalamp.js" ></ script > But this will < script   type = "text/javascript"   src = ' <% =  ResolveUrl("~/Scripts/jquery.lavalamp.js")  %> ' ></ script > So there ya have it. Use the ResolveUrl method to fix those pesky paths once and for all and not have to change it prior to moving to production. Happy Coding.. Merlin

Centering content in a DIV element

Centering contents of a DIV element No this isn't exactly brain surgery but it did stump me for a spell. I laid out a div with a width of 100% and a text-align:center, then I dropped in a table with 2 columns and a fixed width. The desired results was a table centered in the page. Unfortunately that was not the case. I'm not sure why this didn't work, hopefully someone can shed some light on it for me. Here's the code I tried: < div   style = " text-align : center ;  width : 400px ;" >          < table   border = "0"   cellpadding = "0"   cellspacing = "0"   width = "400" >              < tr >                  < td > fdsdf                  </ td >   ...

Ajax AutoCompleteExtender Page Method Magic

Using Page Methods with AJAX Auto Complete Extenders     Using AJAX AutocompleteExtender Page Methods can be a tricky proposal, as I have discovered recently while working on a project. There seems to be a few key settings that seem to be elusive. Countless searches later I have put it all together and though I would share it with with you.         Why use page methods instead of a Webservice file ASMX?? If you only have one extender and/or you want to keep everything in one file, using page methods is a quick way to do it. Here's the quick checklist: Script Manager must have it's EnablePageMethods property set to true Page method must be marked Public and Shared Method must be in the aspx file and not in a user control Method must be marked with   <webmethod> and <Scriptmethod attribute> Method must be declared specifically as outlined below < WebMethod ()> _     <Script.Services. Scrip...

Popular posts from this blog

Handling backspace/delete with AJAX MaskedEditExtender in chrome

Ajax AutoCompleteExtender Page Method Magic

Can Microsoft Windows User Interface Be Trusted? Their AI suggests that we may not.