GeekZilla Recent Articleshttp://www.geekzilla.co.uk/Innovation Team's dumping grounden-usTue, 10 Jun 2003 04:00:00 GMTTue, 10 Jun 2003 09:41:01 GMTGeekZilla.co.ukeditor@GeekZilla.co.ukwebmaster@GeekZilla.co.uk Stopping Focus Highlight on a mx.controls.TextInput in ActionScript on TAB http://www.geekzilla.co.uk/view2CB54F5F-DA90-4907-BC33-B6BF08FB3193.htm Stopping Focus Highlight on a mx.controls.TextInput in Action Script on TAB I recently had a problem with a mx.controls.TextInput which rendered a highlignt area below the TextInput when I tabbed into the control. After much hunting around, I found the following Action Script solution: Basically, add the onSetFocus and onKillFocus event handlers to the TextInput supress the drawFocus(). 23/7/2008 http://www.geekzilla.co.uk/view2CB54F5F-DA90-4907-BC33-B6BF08FB3193.htm The easiest Hex string to/from byte array I've found http://www.geekzilla.co.uk/view11A5080D-B173-41C2-A6CD-F653593B0F74.htm The easiest Hex string to/from byte array I've found When looking for a utility function to convert from a hex string to a byte array, I found this example .. works a treat! http://programmerramblings.blogspot.com/2008/03/convert-hex-string-to-byte-array-and.html Code 18/4/2008 http://www.geekzilla.co.uk/view11A5080D-B173-41C2-A6CD-F653593B0F74.htm Browser version detection in Javascript http://www.geekzilla.co.uk/view90ADED5A-7D59-41BD-8227-42482C915FE3.htm Browser version detection in Javascript Example usage 3/4/2008 http://www.geekzilla.co.uk/view90ADED5A-7D59-41BD-8227-42482C915FE3.htm Geting the position of the mouse pointer (cursor) in JavaScript (Works in IE7) http://www.geekzilla.co.uk/view93D6A395-AABA-408D-9D9A-192424E6EED1.htm Geting the position of the mouse pointer in JavaScript (Works in IE7) The following function will return the position of the mouse pointer based on the event. It actually works in IE7. Example usage 3/4/2008 http://www.geekzilla.co.uk/view93D6A395-AABA-408D-9D9A-192424E6EED1.htm Customise Password Recovery Email http://www.geekzilla.co.uk/view73E1FB90-7A40-467A-AEC6-C2D2F9F1DACB.htm Customise Password Recovery Email The majority of web applications need some sort of authentication component, and ASP.Net's authenication is excellent and allows you all the functionality you would expect. On a recent web application we were required to provide users with the facility to recover their password, and as you'd expect there is a PasswordRecovery component that you just drop on a page and it works. Unfortunately the emails that resulted from the control were not as rich as the client required. i.e HTML and Plain text alternate views, the HTML alternate view also used linked resources so the mail arrives in your mailbox with all its images attached. No need to download the images. After a little bit of thought it was easy to override the PasswordRecovery mails using the SendingMail event. This simple code allows you to override the component's standard email and extract the user's password. With this information you can then insert your own custom mail object and send the recovery information to the user using a template of your choice... Job done.. Hope this helps you out 30/3/2008 http://www.geekzilla.co.uk/view73E1FB90-7A40-467A-AEC6-C2D2F9F1DACB.htm Instanciating an object from it's type name http://www.geekzilla.co.uk/view59C67C5E-91E5-484B-B997-F2528F5C19F4.htm Instanciating an object from it's type name Instanciating a control from it's type name is easy.. One thing you may run into is that in some cases the type name needs to be a fully qualified name.. You can get this name like so: 18/3/2008 http://www.geekzilla.co.uk/view59C67C5E-91E5-484B-B997-F2528F5C19F4.htm Get the Top and Left location of an element with JavaScript http://www.geekzilla.co.uk/view5B49D5AB-871E-4ED5-86B8-36686A5AECB3.htm The following code will return the top and left position for an element. 17/3/2008 http://www.geekzilla.co.uk/view5B49D5AB-871E-4ED5-86B8-36686A5AECB3.htm Returning the first few items from an Array list or IEnumerable collection http://www.geekzilla.co.uk/view3B286690-73F9-41B2-A882-DDAD91647B7F.htm Returning the first few items from an Array list or IEnumerable collection, like T-Sql top() I needed to bind the first 5 items in a List<T> to a repeater. Having recently discovered the .Distinct() extension, I had a look through the other methods attached to my List<T> and found .Take(int) Basic example of using .Take() The output Only the first 5. Example of using .Take() when binding an IEnumerable object to a repeater You may also like to take a look at the .Skip(int) method. It can be used in conjunction with .Take() to help you with paging object data. 20/2/2008 http://www.geekzilla.co.uk/view3B286690-73F9-41B2-A882-DDAD91647B7F.htm Returning a Distinct list of values from an array or IEnumerable cllection http://www.geekzilla.co.uk/viewAC42E918-3A03-45B1-B8EE-2068ACC1DA1C.htm Returning a Distinct list of values from an array or IEnumerable collection I recently had a list of Guids in a string which was returned from a group of checkboxes with identical names. I wanted to itterate through Guids and process each one only once. Basicaly, ignoring duplicates. I didn't have to look very far before I discovered the .Distinct() method. See example below: The output? This triggered me to look at some of the other IEnumerable methods I'd ignored. My favourites so far are: {.Take(int)}http://www.geekzilla.co.uk/View3B286690-73F9-41B2-A882-DDAD91647B7F.htm .Skip(int) .Reverse() 20/2/2008 http://www.geekzilla.co.uk/viewAC42E918-3A03-45B1-B8EE-2068ACC1DA1C.htm Remove Microsoft Internet Explorer Enhanced Security Configuration in Windows Server 2003 http://www.geekzilla.co.uk/viewDA649C4B-754D-4729-9DB3-7251CC99B707.htm Remove Microsoft Internet Explorer Enhanced Security Configuration in Windows Server 2003 In Windows Server 2003, by defualt, browsing is subject many more controls and restrictions. Now where this is a good thing and helps to protect your server from exposure on the internet it is also some what unessesary for administrators as you can add any site to the trusted list and browse to it anyway, but you can't change the Internet zone level from High due to Microsoft's Enhanced Security Configuration. So to remove the Enhanced Security Configuration here are the steps: *Open Add/Remove Programs in Control Panel *Click Add/Remove Windows Components *Scroll down the list to Internet Explorer Enhanced Security Configuration. You can either remove this all together by unchecking the box or, by clicking Details, remove it just for the Administrators groups or all other groups, by unchecking the appropriate box. Click Next and follow the instructions to finish the setup. Now when you go back to IE and do Tools > Internet Options > Security > Internet Zone you will have the option to change the zone level. 29/1/2008 http://www.geekzilla.co.uk/viewDA649C4B-754D-4729-9DB3-7251CC99B707.htm Credit Card Number Ranges http://www.geekzilla.co.uk/view3F00940A-5D51-4736-8DB7-18CDC11C9788.htm Credit Card Number Ranges Here is the basic set of credit card number ranges: ||'''Issuer'''|| '''Identifier'''|| '''Card Number Length''' || ||Diner's Club/Carte Blanche|| 300xxx-305xxx, 36xxxx, 38xxxx|| 14 || ||American Express ||34xxxx, 37xxxx ||15 || ||VISA|| 4xxxxx ||13, 16 || ||MasterCard ||51xxxx-55xxxx ||16 || ||Discover ||6011xx ||16 || More information {Anatomy of Credit Card Numbers}http://www.merriampark.com/anatomycc.htm by Michael Gilleland {Credit Card Number Validator}http://www.tneoh.zoneit.com/javascript/cardobject.html 14/1/2008 http://www.geekzilla.co.uk/view3F00940A-5D51-4736-8DB7-18CDC11C9788.htm Cleaning a string using a regular expression ready for placing in a URL http://www.geekzilla.co.uk/viewFE7A2539-E0EE-4452-A1CC-BC4D18966F0F.htm Cleaning a string using a regular expression ready for placing in a URL 9/1/2008 http://www.geekzilla.co.uk/viewFE7A2539-E0EE-4452-A1CC-BC4D18966F0F.htm Displaying XML like IE in a webpage http://www.geekzilla.co.uk/viewD245BBE0-2EAB-44C0-9119-8038467926EE.htm Displaying XML like IE in a webpage This is everything you need to display XML in your webpage the same way IE displays it when you open an XML document in IE. Html Register the js and place a literal where you'd like the XML to appear. Code Behind Some dummy XML for this example The following applies an XSLt to your xml XSLt The XSLt required for the transformation JS The JavaScript required to expand and collapse the XML document nodes. 4/1/2008 http://www.geekzilla.co.uk/viewD245BBE0-2EAB-44C0-9119-8038467926EE.htm License your .net code http://www.geekzilla.co.uk/view5B9C37E3-233D-4008-BF3D-7DAA01A635FA.htm License your .net code If you're writing code that you intend to sell and install on a client site, you're gonna need to know how to control its use through a license and obfuscation. The following links and attached PDF are a good start with protecting your IP and hard work. http://windowsclient.net/articles/Licensing.aspx Andrew Clark has also suggested the following as a good resource for more information on the topic http://msdn2.microsoft.com/en-us/library/aa479017.aspx 3/1/2008 http://www.geekzilla.co.uk/view5B9C37E3-233D-4008-BF3D-7DAA01A635FA.htm The best CSS rounded corners method http://www.geekzilla.co.uk/viewCFF9FC56-9F47-4E6A-B8C7-0F65BAB287F0.htm The best CSS rounded corners method I love this example : {Even More CSS Roudned Corners 2}http://www.schillmania.com/projects/dialog2/ {Project Home}http://www.schillmania.com/content/projects/even-more-rounded-corners/ {Basic Example}http://www.schillmania.com/projects/dialog2/basic.html The HTML is simple The Css is excellent 27/12/2007 http://www.geekzilla.co.uk/viewCFF9FC56-9F47-4E6A-B8C7-0F65BAB287F0.htm Getting to know Silverlight http://www.geekzilla.co.uk/view30E9FC78-5C92-40B0-8D4B-8844AD865BC9.htm Getting to Know Silverlight One of the most talked-about aspects of Silverlight is its undeniable technical accomplishments. In an age of 50 megabyte downloads, Microsoft managed to squeeze large parts of WPF and a mini-CLR into a tiny browser plug-in, currently under 5MB. Not only that, but it runs in the three major browsers (Firefox, Safari and IE) and more amazingly on the three major operating systems, with Microsoft supporting Windows and Mac OS X and Novell’s Mono project providing a Linux runtime. This article explains a little of the history behind Silverlight and what you can use it for. You’ll see how easy it is to get started, and then you’ll actually practice using a {free InnerWorkings coding challenge}http://www.innerworkings.com/promotions/2b5a0499-9d9b-4bad-96f9-e1e4e1400498/geekzilla-silverlight-promotion featuring a sample app that demonstrates how to use and transform video in Silverlight. Silver-what? Windows Presentation Foundation Everywhere (WPF/E) was announced two years ago at the 2005 PDC (Professional Developer Conference), but kept a low profile for a long time. At Mix ’07 in May however, the first 1.0 beta was released under the Silverlight name, along with (a little confusingly) a preview of the 1.1 release. Version 1.0 has now been officially released and can display vector graphics, animations and high quality video (up to 720p, the low-end of HD). You can program it using a subset of WPF’s XAML syntax, using JavaScript to provide interactivity. Version 1.1 however – still in technical preview stage – is what’s got everyone excited. Much more than a minor revision, this adds a bite-sized CLR to the plug-in, capable of executing compiled C#, VB, Python and Ruby code. Though it is cut-down, the Core CLR still provides a just-in-time compiler and works with the exact same assemblies as the full-blown desktop CLR. If you can restrict yourself to the smaller set of classes included with Silverlight’s CLR, there is complete compatibility between the two, with no re-compilation necessary. How does Silverlight work? From a user’s point of view, the experience is designed to be as smooth as possible. On visiting a Silverlight-enabled site for the first time, a message appears inviting the user to download the plug-in from the Microsoft site. The install is quick and painless, although it can require a browser restart. After that, any Silverlight content is displayed automatically and the plug-in even updates itself as required. The Silverlight SDK makes this experience easy by providing a JavaScript file that detects the plug-in’s presence and either just displays the content or prompts the user to install. The JavaScript also provides a way to display Silverlight content without worrying about the different expectations of the supported browsers. The actual “scene” is defined in XAML, an XML-based format where elements and attributes correspond to .NET objects and their properties. This is the same XAML that powers WPF, just with some of the elements missing. What’s left, at least in Silverlight 1.0, is enough to draw shapes, images, text and video. Some of the flexible layout options from WPF (like the Grid, DockPanel and StackPanel) are missing, along with any kind of prebuilt UI control – there are no buttons, menus, listboxes or anything. Though you can use HTML controls instead, this is a major shortcoming, and the Silverlight team have promised some of these controls for a future release of version 1.1, along with a set of panels to make layout easier. To build an app that does more than just look pretty, you can attach event handlers to Silverlight objects and write code that manipulates the scene, starting animations, controlling video or audio playback and updating the properties of objects. Silverlight really does behave like a mini-WPF, so if you’re familiar with its big brother (or Windows Forms or ASP.NET for that matter), the programming model is easy to follow. Hello, Silverlight When you strip away the helper JavaScript files, very little is required to display Silverlight content in a browser that has the plug-in installed. The snippet below uses inline XAML to reference content defined in the HTML file, but you can just as easily use a file located on your web server (or one generated dynamically by ASP.NET). Other than the XAML script tag, the snippet contains an object tag that actually creates an instance of the Silverlight control, passing it a reference to the XAML it should use (in this case preceded by the # symbol to specify the ID of the HTML element with the content). That’s it. Displaying video with Silverlight One of the strengths of WPF (and so Silverlight) is its composability: objects can be nested within each other easily to create composite objects. A button, for example, doesn’t have to contain just a text label, it could contain an image as well (or a video, or a tiny interactive game, or whatever you want). While many of these uses aren’t, well, useful, the simplicity that composability affords helps with all sorts of more common scenarios. If you want to display an image or video inside a circle or a rounded rectangle, you don’t have to set some obscure property of the image, you just pop it inside a suitably shaped container. In the same way, Silverlight’s animation and transformation features can apply to video as easily as primitive shapes. This makes it easy to render video on objects that can be dragged around, or to zoom into or clip video. The key to this is the VideoBrush, which can be used to paint the interior of a shape with the output of a MediaElement. The MediaElement itself can then be hidden, leaving only the VideoBrush-painted shape visible. Try it out Silverlight is one of those technologies where words alone can’t possibly do it justice. Have a look at the tutorials at {silverlight.net}http://silverlight.net/ to find out more, or skip ahead to {silverlight.net/showcase/}http://silverlight.net/showcase/ to see what can be done. Next, download the {free Silverlight challenges}http://www.innerworkings.com/promotions/2b5a0499-9d9b-4bad-96f9-e1e4e1400498/geekzilla-silverlight-promotion from InnerWorkings and get to grips with some real Silverlight projects. You’ll learn more about setting up Silverlight in your own apps, as well as practice using a VideoBrush to render and control video clipped and magnified according to your own specifications. What’s an InnerWorkings coding challenge? An InnerWorkings coding challenge is a sample of code in Visual Studio that has some key pieces missing. Each challenge includes selected reference links chosen specifically to help you find out how to fill in the blanks, complete the sample app, and learn about a new technology at the same time. Once you’re finished, InnerWorkings Developer automatically checks your code so you can be sure you’ve solved the challenge correctly and that you really understand what you’ve learned. Our coding challenges are designed to take you to the heart of the technology you want to learn more about, focusing on the most important, practical features. Because everything has been set up for you, you can dive straight in and start coding. InnerWorkings has a library of hundreds of challenges on diverse topics from ASP.NET to Windows Communication Foundation. For more information, have a look at our {catalog}http://www.innerworkings.com/Catalog/Catalog.aspx . 17/12/2007 http://www.geekzilla.co.uk/view30E9FC78-5C92-40B0-8D4B-8844AD865BC9.htm Converting a String to a ByteArray in c# http://www.geekzilla.co.uk/view231789E5-CD19-40CC-80AE-ED42943DF2CE.htm Converting a String to a Byte Array in c# Very simple.. here's how to convert a String to a Byte Array in c# #c#byte[] yourByteArray = Encoding.ASCII.GetBytes("your string"); 9/12/2007 http://www.geekzilla.co.uk/view231789E5-CD19-40CC-80AE-ED42943DF2CE.htm Reading a key from the registry in c# http://www.geekzilla.co.uk/viewA77C2D42-E40F-4F1C-9A2B-3D89A8544FEF.htm Reading a key from the registry in c# The following c# code shows how to read a key value from the registry. 9/12/2007 http://www.geekzilla.co.uk/viewA77C2D42-E40F-4F1C-9A2B-3D89A8544FEF.htm Specifying an originator IP Address on a WebService Request using ServicePoint and HttpWebRequest http://www.geekzilla.co.uk/viewAEB5BC13-938A-4DCD-8ACA-9CD2C4A3E065.htm Specifying an originator IP Address on a WebService Request using ServicePoint and HttpWebRequest If you're running multiple IP Addresses on the same NIC in Windows 2003 server and you need a webservice call to originate from a certain one, you'll probably have found the same thing I did. .net uses the default machine IP address. I read some posts about specifying only the IP Address you wanted the request to originate from in IIS 6.0 but that didn't help me at all.. I guess this was because mine were on the same NIC. It took me a while to come up with this solution and I lept for joy when it worked, and made Paul Marshall jump out of his skin. Create a wrapper for your the Web Service you want to call The following code shows my wrapped request to a What's My Ip service: I'd really like to create a Generic wrapper that didn't need to inherit the 2rd party service.. Perhaps using Generics?? Implementation You can see below, I'm specifying the IP address I want the request to originate from. If the IP address does not exist, it will use the machine default. I hope you found this article in time :) 4/12/2007 http://www.geekzilla.co.uk/viewAEB5BC13-938A-4DCD-8ACA-9CD2C4A3E065.htm Set Input Focus on a Control Programatically Added to an ASP.Net Page http://www.geekzilla.co.uk/viewF0289359-2C7F-483A-BFCE-B2B004B89996.htm Set Input Focus on a Control Programatically Added to an ASP.Net Page This little problem had the potential to drive me nuts for hours, I was fortunate to stumble over a blog with 100s of comments re problems of this nature and how to solve it. Most of the discussion was about using JavaScript, then I remembered I was using AJAX in my project and created a solution. '''The Problem''' I had a web page that automatically adds and removes TextBoxs based on a user's input e.g. a user may select "yes" in a DropDownList to a question and we need to get more information, so we add a Please Specify textbox on the postback of the DropDownList . But how on earth do you set the focus?? I tried adding the control to the page and then using its focus command, which didn't work. :-( '''Solution''' Luckly I was using Ajax on the page and I had a ScriptManager in the MasterPage. The script manager pumps out JavaScript, so I used a method on it to set the focus of the control using its client ID. This is the unique ID it is given on the page. Thank goodness for Google. I hope this helps you out.. 1/12/2007 http://www.geekzilla.co.uk/viewF0289359-2C7F-483A-BFCE-B2B004B89996.htm Regex for a HTML tag http://www.geekzilla.co.uk/view42A9B3CF-9E8D-43BD-86FE-C2422FB8F9F3.htm Regex for a HTML tag This can proove invaluable when you're wanting to replace keywords in HTML without spoiling the tags themselves. Particularly useful in SEO. 26/11/2007 http://www.geekzilla.co.uk/view42A9B3CF-9E8D-43BD-86FE-C2422FB8F9F3.htm Regex match html content without screwing up the tags http://www.geekzilla.co.uk/view86FE27C3-E286-4EC7-8275-6E0D8BB58C42.htm Regex match html content without screwing up the tags When needing to highlight words in a string containing HTML we found we soon ran into problems when the word we were searching for appeared in the middle of a tag.. Imagine the example: If I wanted to bold all occurances of geekzilla, I'd usually do this: .. unfortunately, when dealing with HTML rather than just text, this will screw my tag and produce the following We did a lot of googling and found loads of people discussing ways to ignore the tags. Suggetions rainged from sax parsers to character by character loops (nasty). Armed with an excellent regex for matching an entire HTML tag we came up with the following solution Our Solution Use a custom Regex match evaluator to ignore any tags. This works well and is very fast. There may be a slicker way to do this, I hope someone is inspired enough to figure it out and post a comment :) 26/11/2007 http://www.geekzilla.co.uk/view86FE27C3-E286-4EC7-8275-6E0D8BB58C42.htm Backup ALL your SQL Server 2005 databases using ONE script http://www.geekzilla.co.uk/view487F82A5-C96B-4660-A070-F7C8B7FC4431.htm Backup ALL your SQL Server 2005 databases using ONE script I wanted to backup all my databases... I had loads, creating a step for each db was getting tedious, so I wrote this script. Enjoy 20/11/2007 http://www.geekzilla.co.uk/view487F82A5-C96B-4660-A070-F7C8B7FC4431.htm Dynamically adding a CSS link to the page in c# http://www.geekzilla.co.uk/view3214BB4D-8DAC-4149-9168-0D1F7D357432.htm Dynamically adding a CSS link to the page in c# The following code adds a CSS link to the header node of a Html page. 14/11/2007 http://www.geekzilla.co.uk/view3214BB4D-8DAC-4149-9168-0D1F7D357432.htm Scrollbar CSS style generator http://www.geekzilla.co.uk/viewAA1BFC74-3A14-459A-A100-334AFC29E495.htm Scrollbar CSS style generator Excellent online tool for generating css for scrollbars http://iconico.com/CSSScrollbar/ 12/11/2007 http://www.geekzilla.co.uk/viewAA1BFC74-3A14-459A-A100-334AFC29E495.htm Excellent IIS Metabase Helper http://www.geekzilla.co.uk/view892617D9-06D4-4F77-A47A-1611AA790398.htm Excellent IIS Metabase Helper Found this : http://agramont.net/blogs/provware/default.aspx http://agramont.net/blogs/provware/archive/2006/07/31/Provware_3A00_-Getting-Started-_2800_Build-001_2900_.aspx Has the potential to be an excellent Metabase wrapper. 7/11/2007 http://www.geekzilla.co.uk/view892617D9-06D4-4F77-A47A-1611AA790398.htm Preventing Caching of an ASP.net page in c# http://www.geekzilla.co.uk/view4198D1B2-65AE-4632-B45E-164EE86C790B.htm Preventing Caching of an ASP.net page in c# The following code prevents a page being cached. 5/11/2007 http://www.geekzilla.co.uk/view4198D1B2-65AE-4632-B45E-164EE86C790B.htm Getting the Virtual Path of a Request in c# http://www.geekzilla.co.uk/viewC93F8521-8014-4CB9-8989-F2E2403A8D76.htm Getting the Virtual Path of a Request in c# This simple bit of code will get you the '''Virtual Path''' of your current request. Example Usage Notes Don't forget to include: 5/11/2007 http://www.geekzilla.co.uk/viewC93F8521-8014-4CB9-8989-F2E2403A8D76.htm Fixing Form Action on UrlRewrite (UrlRewriter) http://www.geekzilla.co.uk/view0472D2E7-4653-46B1-AC36-5EA246B17D22.htm Fixing Form Action on UrlRewrite IF you're rewriting URL's, you've probably come across the same problem I had. When posting back on the page, the real URL is used.. this is a real pain if you're writing a page which uses the '''RawUrl''' to serve up relevant content. I had a good look around the web for a solution. These ranged from creating a custom HtmlForm control to replacing the form tag in the App_Browsers folder. The following is simple and worked for me. Place the following code in the Page_Load of the page you're serving up. Hope this helps. 5/11/2007 http://www.geekzilla.co.uk/view0472D2E7-4653-46B1-AC36-5EA246B17D22.htm Custom Validators using Client Side JavaScript http://www.geekzilla.co.uk/viewD27B15B4-71A4-4258-81EE-9445FAA9F634.htm Custom Validators using Client Side JavaScript In my latest project I am really enjoying using the Ajax Control Toolkit, particularly the ModalPopupExtender. I've been using the popup panels to capture data, but I needed to validate the data that a user enters into certain fields. ASP.net's validators are the obvious choice, but when you have employed an AJAX control you need to validate the entry on the client's browser. This is easy to do using the '''ClientValidationFunction''' attribute of the validator. then create a JavaScript function to do the validation. Here I have created a Regular Expression to validate decimals. Then simply set the args.IsValid property to either true or false and return. In this example I have used the ScriptManager to write out a JavaScript variable ('''DiscountPercentageId''') with the ClientID of the ASP.net TextBox I'm validating. You'll also notice my GetElement function to handle the browser compatibility. I hope this proves useful in your next AJAXian web application. ;-) 2/11/2007 http://www.geekzilla.co.uk/viewD27B15B4-71A4-4258-81EE-9445FAA9F634.htm Awesome Sidebar Gadget http://www.geekzilla.co.uk/view87DD6679-CB41-4214-8BFA-EA830C6F3892.htm Awesome Sidebar Gadget This gadget is awesome '''(ESPECIALLY IN LARGE MODE)''': http://gallery.live.com/liveItemDetail.aspx?li=426dc418-12ce-481a-b886-89a66ca9127e System Control is much more than your average shutdown gadget. Aside from the normal Shutdown, Restart, Lock, and Sleep / Hibernate, we give you Switch User, Log Off, Task Manager, Run Window, and Command Prompt. All of those buttons can be re-ordered or disabled / enabled. This gadget has two sizes: Small, which accommodates 3 buttons at a time, and Large which gives you the ability access all the buttons at once. In addition to that, we have 10 themes at your disposal. Worried about accidentally shutting your machine down? No problem. We have an in-gadget confirmation for buttons with greater functionality. We also have a lock button in case you need it. In addition to the buttons, we also have the time below, which can be changed in the settings panel to: 3 different time formats, date format, overall CPU usage, overall RAM usage, or just plain nothing. It’s small, sleek, powerful, and very customizable. New 1.2 Update! Website: BuildAGadget.com 30/10/2007 http://www.geekzilla.co.uk/view87DD6679-CB41-4214-8BFA-EA830C6F3892.htm Date Regular Expression (dd/MMM/yyyy) http://www.geekzilla.co.uk/view653502BD-00B7-4012-9786-F941208F5F0C.htm Date Regular Expression (dd/MMM/yyyy) The following matches: *01/JAN/2007 *22/Feb/2006 But doesn't match: *01/01/2007 *22/02/2007 *01 Jan 2007 #c#^(([0-9])|([0-2][0-9])|([3][0-1]))\/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\/\d{4}$ 26/10/2007 http://www.geekzilla.co.uk/view653502BD-00B7-4012-9786-F941208F5F0C.htm Hex code Regular Expression (#F0F0F0) http://www.geekzilla.co.uk/view05C802F8-F1DF-4097-A969-0EACB51C7834.htm Hex code Regular Expression (#F0F0F0) The following matches valid HTML hexadecimal color codes. The # symbol is optional. It will except either the 3 digit form for the 216 Web safe colors, or the full 6 digit form. #c#^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$ 12/10/2007 http://www.geekzilla.co.uk/view05C802F8-F1DF-4097-A969-0EACB51C7834.htm Email Regex Pattern http://www.geekzilla.co.uk/view5A571933-A163-4A8F-B150-3357B4558AFA.htm Email Regex Pattern #c#^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$ 12/10/2007 http://www.geekzilla.co.uk/view5A571933-A163-4A8F-B150-3357B4558AFA.htm Time Regular Expression http://www.geekzilla.co.uk/viewA9DC7ADA-887E-4017-A6CA-B8AD78B1FAF8.htm Time Regular Expression #c#^([0-1][0-9]|[2][0-3]):([0-5][0-9])$ 12/10/2007 http://www.geekzilla.co.uk/viewA9DC7ADA-887E-4017-A6CA-B8AD78B1FAF8.htm How to get more than 3GB in Windows Vista 32-bit http://www.geekzilla.co.uk/view090A0DC0-6AB2-441A-94E6-E1BFDCDC5D0B.htm How to get more than 3GB in Windows Vista 32-bit Out if the box, Vista (32-bit) only detects a maximum of 3GB of RAM. You're probably gutted if you just bought a 4GB PC. Vista 32-bit systems can actually detect 4GB RAM (and more!). Sometimes the O.S. does not see the 4th GB of RAM but that can be remedied by typing the following command '''(as Administrator)''': This forces Windows Vista X32 to use 4 or more GB of RAM. (PAE stands for Physical Address Extension) For more information on BCDEdit see: http://msdn2.microsoft.com/en-us/library/aa906211.aspx 13/9/2007 http://www.geekzilla.co.uk/view090A0DC0-6AB2-441A-94E6-E1BFDCDC5D0B.htm Creating your first ASP.NET AJAX 1.0 Application http://www.geekzilla.co.uk/viewB6B709B4-5697-40EE-8429-CB09A453A94F.htm Creating your first ASP.NET AJAX 1.0 Application Over the last year or so, AJAX has taken the web development world by storm. AJAX is short for Asynchronous JavaScript and XML and is an approach to building dynamic web applications that behave less like the static web pages we're used to and more like desktop applications. At the heart of AJAX is the XmlHttpRequest object, a component originally designed by Microsoft and used to provide the rich Outlook-like interface of Exchange Web Access. JavaScript on a web page can use an instance of XmlHttpRequest to send requests to the web server that generated the page and then use the response to update part of the page, without the browser having to reload everything. This can make the application a lot quicker -- instead of the entire page having to be transmitted and rendered, the browser just fetches what's needed to update the current page. Although the technologies that support AJAX-style web apps have been around for years, they weren't widely used until the introduction of frameworks that made dealing with the extra complexity, not to mention cross-browser differences, possible. {Microsoft's ASP.NET AJAX framework}http://ajax.asp.net/ is one of the most recent, and has just been released as version 1.0, following a year of pre-releases that used the code name "Atlas". This article shows you how to AJAX-enable an existing ASP.NET web page by using Microsoft's ASP.NET AJAX Extensions. The UpdatePanel control provided by the framework makes it really easy to start with AJAX programming by defining the areas of the page you want to update independently without a full page reload. Once you've understood the basics, you'll use an {InnerWorkings}http://www.innerworkings.com/ coding challenge that provides a sample AJAX-enabled bug tracking website to help you really understand how to use the AJAX Extensions. [[bugtracker.png]] What is Microsoft ASP.NET AJAX? Microsoft ASP.NET AJAX is a free framework designed to make it easier to write modern AJAX-style applications using ASP.NET. There are two parts to the framework -- a cross-browser JavaScript library and a set of server-side ASP.NET controls. The JavaScript library goes beyond simply enabling AJAX apps and provides object-oriented extensions to JavaScript to make it easier to write complex applications that need to process a lot of data in the browser. On the server-side, a set of new and enhanced ASP.NET controls make it possible to write AJAX applications by simply adding controls to a page, just as with non-AJAX applications. In fact, you don't have to write a single line of JavaScript to create a fully-featured AJAX application. As well as ASP.NET AJAX itself, there are two other downloads available to add AJAX functionality to your site. The {AJAX Futures CTP}http://www.microsoft.com/downloads/details.aspx?FamilyId=A5189BCB-EF81-4C12-9733-E294D13A58E6&displaylang=en (Community Technical Preview) is a collection of new features which will be added to the main AJAX Extensions framework in the future. The {AJAX Control Toolkit}http://www.codeplex.com/AtlasControlToolkit contains prewritten components like panels that can be dragged around the page and rating controls to enable users to submit feedback. What's an InnerWorkings Developer Coding Challenge? An InnerWorkings Developer coding challenge is a sample of code in Visual Studio that has a couple of key pieces missing. Each challenge includes selected reference links chosen specifically so you can easily find out how to fill in the blanks, complete the sample app, and learn about a new technology at the same time. Once you're finished, InnerWorkings Developer automatically checks your code so you can be sure you've solved the challenge correctly and that you really understand what you've learned. The coding challenges are designed to take you to the heart of the technology you want to learn more about, focusing on the most important, practical features. Because everything has been set up for you, you can dive straight in and start coding. InnerWorkings Developer has a library of hundreds of challenges on topics from ASP.NET to Windows Communication Foundation. For more information, have a look at our {catalog}http://www.innerworkings.com/catalog . How Does the UpdatePanel Work? The UpdatePanel is designed to be the easiest possible way to AJAX-enable your site, focusing on the most important feature of AJAX: restricting updates to an area within a page instead of requiring a full refresh. Although it completely changes how requests are made by the browser, the UpdatePanel is written in such a way that your pages execute normally, which means you don't have to rewrite any controls or server-side logic. As the browser loads the AJAX framework, a JavaScript onsubmit handler is added to every form element on the page. When the form submits, the handler checks whether this should be a "partial update" -- one handled by an update panel. If so, it collects all the data being sent to the server, repackages it, and sends it, not as a regular browser request, but using the XmlHttpRequest object. In the browser, the onsubmit handler now returns false, effectively telling the browser to cancel the full page refresh. Meanwhile, the request has made its way to your web server looking just like a normal request with one difference: an extra HTTP header lets the AJAX infrastructure know that this is a partial update. The page executes as normal and the output is collected ready to be sent to the browser. Just before it's sent however, another bit of AJAX magic kicks in. Everything that isn't needed for the UpdatePanel is stripped out and some extra data is sent (including updated hidden fields and ViewState for controls not included in the UpdatePanel). When this arrives back at the browser, the JavaScript library updates everything, including the contents of the UpdatePanel, but also all the extra data. If your ASP.NET page updates the page title or even the page's CSS styles, all of these are updated automatically. Using the UpdatePanel Despite all this automatic support, using the UpdatePanel couldn't be simpler. There's a little install work -- once the AJAX extensions are installed, there are only a couple of additions to your web.config file to paste in. (The easiest way to add these is simply to copy the sample config file which should be installed to C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\web.config or somewhere similar, depending on where you installed the extensions.) After that you can AJAX-enable your website by adding just two tags to your webpage: a ScriptManager and the UpdatePanel itself. The ScriptManager control manages the AJAX JavaScript libraries and writes <script> tags to tell the browser what to download. This process is mostly automatic, although you can also configure the control to include your own scripts, or to generate JavaScript for calling web services hosted on your server. To add a ScriptManager to your page, just add a ScriptManager tag to any server-side form within the page. The UpdatePanel is used to define the section of the page that should update without a full page refresh. To use the default features, just enclose the part of the page you want to AJAX-enable in a matching pair of UpdatePanel and ContentTemplate tags. In the example below, the SubmitButton and ResponseLabel tags are inside the UpdatePanel -- when the SubmitButton is clicked, a message appears without the page refreshing. To see how the page updates without using AJAX, you can comment out the UpdatePanel and ContentTemplate tags, leaving the Button and Label tags in place. [[birthday.png]] Try It Out As you can see, adding the UpdatePanel to an existing page couldn't be much simpler, but there's a lot more to the AJAX extensions than just the UpdatePanel. A great place to start if you want to see what's possible is the {ASP.NET AJAX showcase}http://www.asp.net/ajax/showcase/default.aspx . Next, download the {free ASP.NET AJAX Drill}http://www.innerworkings.com/promotions/c8226eee-ac57-4603-995b-0a766a3a20cb/geekzilla-ajax-promotion from InnerWorkings and see how to use the Update Panel in a real application. Once you've solved the challenges it contains, you'll know you're ready to start using AJAX in your next project. 7/9/2007 http://www.geekzilla.co.uk/viewB6B709B4-5697-40EE-8429-CB09A453A94F.htm GeekZilla Google Analytics Report August 07 http://www.geekzilla.co.uk/view5D02C8E2-9954-456E-86C6-CC6ABBE59DF9.htm GeekZilla Google Analytics Report August 07 [[geekzila_august.gif]] 3/9/2007 http://www.geekzilla.co.uk/view5D02C8E2-9954-456E-86C6-CC6ABBE59DF9.htm Display CreateUserWizard Error Messages using a ContentTempate http://www.geekzilla.co.uk/view521AFCB5-0CB8-4FFD-A45A-2EE24ADC7FFE.htm CreateUserWizard Error Messages using a ContentTempate In our latest project we are implementing Membership, Roles and Profiles. I've used these before, but never really had the need to exploit all the features. The business requirements of the system have meant that I have had to implement a custom CreateUserWizard ContentTemplate, which is great feature of the control. I can set all of the error message properties, but I just couldn't work out how to get my custom error text onto the screen. I even tried putting code into the '''OnCreateUserError''' event to trap an error and display the error text, and this doesn't work because the error text in the event isn't what you specified in the control. After trawling the web, I found the solution. The Control must look for this literal when it is in error, and populates it. :-) How easy was that?! I'd normally close by suggesting a beer, but its too early on a sunday.. :-( Hope this helps someone. 12/8/2007 http://www.geekzilla.co.uk/view521AFCB5-0CB8-4FFD-A45A-2EE24ADC7FFE.htm Adding a Strong Name to an existing DLL that you don't have the source to http://www.geekzilla.co.uk/viewCE64BEF3-51A6-4F1C-90C9-6A76B015C9FB.htm Adding a Strong Name to an existing DLL that you don't have the source to There are times when you need a DLL to have a strong name; putting it in the GAC for example. With 3rd party DLL's this could be a pain. This is how you do it: From a VS.NET command prompt, enter the following: '''1. Generate a KeyFile''' '''2. Get the MSIL for the assembly''' '''3. Rename the original assembly, just in case''' '''4. Build a new assembly from the MSIL output and your KeyFile''' Where do these tools live If you've not got your framework and sdk paths properly mapped... In framework 2 this is where the command line utilities live: *C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\'''ilasm.exe''' *C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\'''ildasm.exe''' *C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\'''sn.exe''' 7/8/2007 http://www.geekzilla.co.uk/viewCE64BEF3-51A6-4F1C-90C9-6A76B015C9FB.htm Error connecting to undo manager of source file xxxx.aspx.designer.cs http://www.geekzilla.co.uk/view6B84F013-FEBA-4B81-8A3E-FCE1D720B867.htm Error connecting to undo manager of source file '''The Problem''' If you are using the Web Application Project Template (with as the Add On or as part of SP1) you can get this error. This error can simply appear at any time for no apparent reason. There have been several suggestions on the web on how to get around this involving excluding files and rebuilding. These solutions will not work if it is a referenced page or user control though. '''The Solution''' * Delete the offending designer file * Right click on the aspx or ascx and choose '''Convert to Web Application''' * Done 3/8/2007 http://www.geekzilla.co.uk/view6B84F013-FEBA-4B81-8A3E-FCE1D720B867.htm Fixing Actionscript XML newline problem http://www.geekzilla.co.uk/viewD27F7A43-5DA4-432A-A683-C8AB9D5F4CC4.htm Fixing Actionscript XML newline problem I was having a nightmare with a newline '''\n''' coming through from an XML document literally as \n when I passed the text into a DynamicText object in ActionScript 2, Flash CS3. Mark Page found this solution: It works beautifully! 2/8/2007 http://www.geekzilla.co.uk/viewD27F7A43-5DA4-432A-A683-C8AB9D5F4CC4.htm GeekZilla Google Analytics Report July 07 http://www.geekzilla.co.uk/view3C299AD7-BD54-4FAA-8390-B315DB4CC1C0.htm GeekZilla Google Analytics Report July 07 [[last30days.gif]] 2/8/2007 http://www.geekzilla.co.uk/view3C299AD7-BD54-4FAA-8390-B315DB4CC1C0.htm Custom JavaScript attributes work differently in IE compared to Firefox http://www.geekzilla.co.uk/viewA8EC1850-F754-416A-8A93-D9406725747C.htm Custom JavaScript attributes work differently in IE compared to Firefox Adding custom attributes to HTML tags is a really valuable programming method. It's something I do quite often. Consider the following code: The above code would work in IE6+ but would fail in Firefox. The solution In Firefox you need to use one of the following alternatives to read the attribute value back (these also work in IE) I guess we should all be using these rather than the helpful IE code... old habits die hard though. 1/8/2007 http://www.geekzilla.co.uk/viewA8EC1850-F754-416A-8A93-D9406725747C.htm Firefox doesn't use parentElement, it uses parentNode http://www.geekzilla.co.uk/view1DC6D1A6-3791-42F0-B94C-6D158A4B9E86.htm Firefox doesn't use parentElement, it uses parentNode JavaScript in FireFox doesn't support the function parentElement. You should use parentNode instead. Example: #h#myElement.parentNode; 1/8/2007 http://www.geekzilla.co.uk/view1DC6D1A6-3791-42F0-B94C-6D158A4B9E86.htm Setting default collation on a column http://www.geekzilla.co.uk/view2872FF14-315E-4C3C-BB73-4950B8241B8E.htm Setting default collation on a column The following will set the collation on a column in a table back to Database Default without dropping and recreating the table (unlike Enterprise Manager) 30/7/2007 http://www.geekzilla.co.uk/view2872FF14-315E-4C3C-BB73-4950B8241B8E.htm Presenting Leading Zeroes in a Query http://www.geekzilla.co.uk/view9D3030FC-458A-4C03-A9E9-6CB2A7979E82.htm Presenting Leading Zeroes in a Query This little tip came in handy for me when sorting objects by their position within a tree structure. If you build up a string such as 0.0.1.0 representing the nodes position within a tree structure then sorting will result in an ascii sort where 0.0.10.0 comes before 0.0.2.0 - not what you would want. This can be resolved by simply pre-pending some leading zeroes to each number in the list, giving something like 0000.0000.0010.0000 which would give you the sort order you are after. Anyway, enough of my chat, here is the code. This will return '0010'. Hope that is useful to someone out there - even if not for sorting tree nodes. 30/7/2007 http://www.geekzilla.co.uk/view9D3030FC-458A-4C03-A9E9-6CB2A7979E82.htm Parameter Order Wrong With ObejctDataSource http://www.geekzilla.co.uk/view3719CCEA-FB17-4497-9395-8E4979707726.htm Parameter Order Wrong With ObejctDataSource http://www.p1tp.com/images/ods%20parameters.gif This one came up today and I felt in a sharing mood. I had a GridView using and ObjectDataSource (ODS) and this was used for automatic updates via Inplace editing. When updating the GridView this would then call the UpdateMethod of the ObjectDataSource, but it would fail with the above error. After a little playing, it turns out that if you have got some of your columns in a GridView set to ReadOnly Visible=false, then there is no way of guranteeing the order of the parameters passed through to the UpdateMethod of the ODS. To get around this little problem, you can either create an Update Method on your Custom Object that supports the method signature being passed through, or the better option is to hack the parameter order that is passed through. In order to change order of the Parameters passed through you need to hook in into the Bold"Updating" event of the Object Datasource and Pass in the params in the order that you want. There is no way of actually re-ording the parameters in the InputParameters collection, so you need to copy them out then put them back in the order that you want. The following code demostrates my implementation of this:- #c#} 26/7/2007 http://www.geekzilla.co.uk/view3719CCEA-FB17-4497-9395-8E4979707726.htm Comments now use Wiki text http://www.geekzilla.co.uk/viewDD13DA77-670E-4C2A-9510-0967A07E543E.htm Comments now use Wiki text Comments added to articles now use wiki text.. this means you can paste code, include hyperlinks, use smileys. To paste code : add 26/7/2007 http://www.geekzilla.co.uk/viewDD13DA77-670E-4C2A-9510-0967A07E543E.htm Returning a value from a PageMethod http://www.geekzilla.co.uk/view30F417D1-8E5B-4C03-99EB-379F167F26B6.htm Returning a value from a PageMethod using MS AJAX '''NOTE: This is designed for v1.0.61025.0 of AJAXExtensionsToolbox.dll''' If you've ever returned data from a web service using MS AJAX this technique will look familar. Call the method from javascript by append PageMethods. to the front of the method name. Add a delegate to the end of the method's parameters to get the result. I have made the source to this available to download, otherwise take a look at the full explanation below: Full explanation - Step 1 - Enable Page Methods on your ScriptManager Set the '''EnablePageMethods''' attribute to true Step 2 - Mark your method as static and give it the '''WebMethod''' attribute The method has to be declared '''static'''. It must also be marked with the WebMethod attribute. You'll probably find that you need to include System.Web.Services Step 3 - Call it from Javascript Call the method from javascript by append PageMethods. to the front of the method name. Add a delegate to the end of the method's parameters to get the result. 26/7/2007 http://www.geekzilla.co.uk/view30F417D1-8E5B-4C03-99EB-379F167F26B6.htm