Tuesday, 14 July 2009

URL Shorteners Article

A friend of mine threw this up on twitter and I thought i’d make a note of it here!

URL Shorteners: Which Shortening Service Should You Use?

Ok yes I am a nerd – but I found this very useful in explaining this functionality used on services such as twitter and how search engines are dealing with these links.

Thursday, 9 July 2009

Silverlight 2 and Deep Zoom Composer comments no.1

This is the beginning of I suspect a series of notes on Silverlight 2/3 and related technologies, I have the joy to play around with. I wanted to start with a few example links to

A good place to start is to go to the Microsoft Silverlight website and the MSDN sites:

http://silverlight.net/Default.aspx

http://msdn.microsoft.com/en-us/library/cc838158(VS.95).aspx

A very useful Silverlight debugging tool:

http://silverlightspy.com/silverlightspy/download-silverlight-spy/

Some interesting articles relating to a modal windows:

http://silverlightmodal.codeplex.com/

And deep zoom image composers

http://blogs.msdn.com/expression/archive/2008/11/26/hello-deepzoomtools-dll-deep-zoom-image-tile-generation-made-easy.aspx

http://msdn.microsoft.com/en-us/magazine/dd943052.aspx

I’ll write more later and start including some examples on my website :)

Monday, 29 June 2009

Switching Between HTTP and HTTPS Automatically

I needed some code to automatically redirect a user from http to https. My friend Kamil came to the rescue and forwarded me a link to this code component:

Matt Sollars - Web Page Security

Of course you could just have a response redirect on default.aspx but I wanted something a lot more elegant and this did exactly that.

Although the whole of my site had to be secure, it was pretty clear here how to restrict https to certain directories or files with relative ease using web.config.

The code extends the IHttpModule and therefore can be easily configured to work for all files and removes the necessity to embed code into all pages.

Tuesday, 26 May 2009

Welsh on Windows Server 2003

Beware if you want to use cy-GB locale on Windows Server 2003 - you will need to update to Service Pack 2 - as this locale is not present in the original release or service pack 1.

If you cannot upgrade to service pack 2, I found a useful resource on the University of Wales - Bangor - language technology website.

I have repeated the relevant information here for future reference:

1. Create a cy-gb.ldml with the C# code by running the following code on a windows XP SP2 machine (NB this references the following Sample code for getting ELK cultures on other platforms by Michael Kaplan).

   1: using System;
   2: using System.Globalization;
   3:  
   4: namespace Testing 
   5: {
   6:     class Test 
   7:     {
   8:             [STAThread]
   9:             static void Main(string[] args) {
  10:                 CultureAndRegionInfoBuilder carib = new CultureAndRegionInfoBuilder("cy-GB", CultureAndRegionModifiers.Replacement);
  11:                 carib.LoadDataFromCultureInfo(new CultureInfo("cy-GB", false));
  12:                 carib.LoadDataFromRegionInfo(new RegionInfo("cy-GB"));
  13:                 carib.Save(@"c:\cy-GB.ldml");
  14:             }
  15:         }
  16:     }
  17: }

2. Copy the cy-gb.ldml file to your Windows 2003 (or Windows 2000) machine

3. Open the cy-gb.ldml file in Notepad or any text editor and search for the lines containing :


   1: msLocale:textInfoName type="cy-GB"
   2: msLocale:sortName type="cy-GB"

and change them to


   1: msLocale:textInfoName type="en-GB"
   2: msLocale:sortName type="en-GB"

Then register your new ‘custom locale’ by executing the following code on the Windows 2003 box:

   1: using System;
   2: using System.Globalization;
   3:  
   4: namespace Testing {
   5:       class Test {
   6:           [STAThread]
   7:           static void Main(string[] args) {
   8:               CultureAndRegionInfoBuilder carib = CultureAndRegionInfoBuilder.CreateFromLdml(@"c:\cy-GB.ldml");
   9:               carib.Register();
  10:           }
  11:       }
  12:   }

NB - to compile the code you can use the following:

   1: csc /r:sysglobl.dll welsh.cs

So should all be okay now!!

Tuesday, 28 April 2009

Fixing Display Issue with IE6 and AJAX toolkit Modal Popup Extender

I had a bit of a nightmare trying to get the modal popup extender working when viewing a webpage containing this Ajax control in IE6. My thoughts regarding IE6 are best left out of this!! After some digging I found several articles that pointed to a variety of things - this is what worked for me.

As I was working with a page which relied on a series of masters I could not change the “doctype”.

This left me to hack the source of the Ajax toolkit. If you open this solution, and look at the JavaScript the answer lies there.

This works with v1.0.10123.0

1. Change the file Common.js which is found at AjaxControlToolkit\Common\Common.js
2. Search for a method called 'getClientBounds'
3. Replace switch with



   1: switch(Sys.Browser.agent) {
   2:     case Sys.Browser.InternetExplorer:
   3:         if (document.documentElement && document.documentElement.clientWidth)
   4:             clientWidth = document.documentElement.clientWidth;
   5:         else if (document.body)
   6:             clientWidth = document.body.clientWidth;
   7:         if (document.documentElement && document.documentElement.clientHeight)
   8:             clientHeight = document.documentElement.clientHeight;
   9:         else if (document.body)
  10:             clientHeight = document.body.clientHeight;
  11:         break;
  12:     case Sys.Browser.Safari:
  13:         clientWidth = window.innerWidth;
  14:         clientHeight = window.innerHeight;
  15:         break;

4. Important part is the next bit - as absolute positioning is not correctly implemented in IE6. Look for the initalize function and look for the background i.e.

replace this line:



   1: this._foregroundElement.style.position = 'fixed'; 

with



   1: if (this._isIE6)
   2:   this._foregroundElement.style.position = 'fixed';
   3: else
   4:   this._foregroundElement.style.position = 'absolute';

and this line:


   1: this._backgroundElement.style.position = 'fixed';

withp>



   1: if (this._isIE6)
   2: this._backgroundElement.style.position = 'fixed';
   3: else
   4: this._backgroundElement.style.position = 'absolute';

This should solve the problem.

Monday, 16 March 2009

AJAX Drag Panel toolkit – drag panel issue with IE6

I found another issue with IE6 today relating to a drag panel ajax extender I was implementing in a page. First of all when I moved the drag panel to the right hand side of the screen the panel was changing size. This is likely to be related to the panel conforming to the width set on its parent container.

The drag panel code:

   1: <asp:Panel ID="pnlDetailsContainer" runat="server" style="display:none;" CssClass="containerBox">
   2:     <asp:Panel ID="pnlDetailsHeader" runat="server" CssClass="popupBoxHeader">
   3:         ....        
   4:     </asp:Panel>
   5:     <div class="pnlDetailsMarkup">
   6:         ...some markup...
   7:     </div>
   8: </asp:Panel>

The CSS:

   1: .containerBox
   2: {
   3:     border-style:solid;
   4:     border-width:2px;
   5:     border-color:Black;
   6:     background-color:#ffffff;
   7:     width:300px;
   8: }

To fix this resizing problem i put the whole panel into a surrounding div:


   1: <div class="detailsContainer">
   2: ...panel..
   3: </div>

Set the width and height parameters in CSS and it works fine in IE7 and Firefox 3. But not IE6. For some reason in IE6 it puts the div in and therefore moves other page elements out of place instead of just showing when required.

To fix this I set an IE6 specific style to a height and width 1px. This had the desired effect.

Tuesday, 10 February 2009

HTML - Special Entity Codes - useful link

I found this link today which is very useful for finding those special entity codes for html.

HTML - Special Entity Codes

Friday, 30 January 2009

Displaying really large text files over 3GB in size

I ran a data importer process last night and ended up with a log of 3.3GB nice :) Found this useful tool to be able to view it - poor old notepad hasn't a chance.

http://www.swiftgear.com/ltfviewer/features.html

Tuesday, 27 January 2009

Tag Clouds for Blogger

I found this useful tag cloud for blogger.

Simple Tag Cloud Widget for Blogger

I've replicated the code below just in case the above link does not work. All you need to do is add a label widget and change its code to the following:

   1: <b:widget id='TagCloud' locked='false' title='Tags' type='Label'>
   2:     <b:includable id='main'>
   3:     <b:if cond='data:title'>
   4:       <h2><data:title/></h2>
   5:     </b:if>
   6:     <div class='widget-content' style='text-align: justify;'>
   7:          <script type="text/javascript">
   8:         /*
   9:         Simple Blogger Tag Cloud Widget
  10:         by Raymond May Jr.
  11:         http://www.compender.com
  12:         Released to the Public Domain
  13:         */
  14:         //Variables:
  15:         var max = 150; //max css size (in percent)
  16:         var min = 50; //min css size (...)
  17:         var showCount = 1;  // show counts? 1 for yes
  18:         var minCount = 1;  // what is the minimum count for a Tag to be shown? 1 for all.
  19:         
  20:         //Begin code:
  21:         var range = max - min;
  22:  
  23:         //Build label Array
  24:         var labels = new Array();
  25:          <b:loop values='data:labels' var='label'>
  26:            labels.push("<data:label.name/>");
  27:          </b:loop>
  28:  
  29:         //URLs
  30:         var urls = new Array();
  31:          <b:loop values='data:labels' var='label'>
  32:            urls.push("<data:label.url/>");
  33:          </b:loop>
  34:         
  35:         //Counts
  36:         var counts = new Array();
  37:          <b:loop values='data:labels' var='label'>
  38:            counts.push("<data:label.count/>");
  39:          </b:loop>
  40:         
  41:         //Number sort funtion (high to low)
  42:         function sortNumber(a, b)
  43:         {
  44:          return b - a;
  45:         }
  46:         
  47:         //Make an independant copy of counts for sorting
  48:         var sorted = counts.slice();
  49:         
  50:         //Find the largest tag count
  51:         var most = sorted.sort(sortNumber)[0];
  52:         
  53:         //Begin HTML output
  54:         for (x in labels)
  55:         {
  56:              if(x != "peek" && x != "forEach" && counts[x] >= minCount)
  57:              {
  58:                   //Calculate textSize
  59:                   var textSize = min + Math.floor((counts[x]/most) * range);
  60:                   //Show counts?
  61:                   if(showCount == 1)
  62:                   {
  63:                        var count = "(" + counts[x] + ")";
  64:                   }else{
  65:                        var count = "";
  66:                   }
  67:                   //Output
  68:                   document.write("<span style='font-size:" + textSize + "%'><a href='" + urls[x] + "'>" + labels[x] + count + "</a></span> " );
  69:              }
  70:             }
  71:             </script>
  72:         </div>
  73:     </b:includable>
  74: </b:widget>

Sunday, 11 January 2009

Case Insensitive filters on Telerik RadGrid

Very useful

Here's how to disable the case-sensitive filters on a Telerik grid:

RadGrid1.GroupingSettings.CaseSensitive = false;

From Beccy.net blog.