Create your own configuration settings with ConfigurationSetting

by Dominic Zukiewicz 23. June 2008 11:17
I remember a while ago writing an application and wanting to feed in some configuration settings. I was just using AppSettings, but the problem was that all settings were strings, so I had to cast several variables, and write loads of error checking just to get the application up and running. The application in question had several settings including a mixture of booleans, integers and strings. I had to parse them and then error check these values, to make the application more stable. It did create a heap of try/catch blocks that, as you will see are now unnecessary. Here is how the applicati... [More]

Tags:

NickServ and HydraIRC

by Dan Matthews 23. June 2008 10:11
I've been hanging out on the #epicode IRC channel for the past few months, and over time I've played with several IRC clients such as XChat, Mibbit (for the Web) and HydraIRC. One of the things that you do most often on IRC is /msg people. The server that I use for #epicode is FreeNode. This server requires you to register you nick before doing a /msg. If you try to /msg without registering, you get an error message back from the server. XChat, annoyingly, didn't show me the IRC error and I spent quite some time trying to figure out what was wrong. Mibbit behaves nicely, but you have to enter ... [More]

Tags:

EPiServer

Using delegates to simulate WaitHandle.WaitAll() calls for web service - Part 2

by Dominic Zukiewicz 17. June 2008 07:58
In the first part of this article, I discussed the option of calling multiple web services and waiting for them to all return. It turns out you can do it quickly with a method call that already existed: public List GetProducts( int[] productCodes ) { ArrayList asyncStore = new ArrayList(); List<int, ProductWebService.Product> products = new List<int, ProductWebService.Product>(); ProductWebService.Products service = new ProductWebService.Products();   service.GetProductDataCompleted += new GetProductDataCompletedEventHandler(GetProductData... [More]

Tags:

Web Services and .NET Remoting

EPiServer: Dynamic SiteMap.xml generator for Google

by Brad 12. June 2008 10:09
Having stumbled across Google's Webmaster Tools a while ago it's been in the back of my mind to create a custom HttpHandler to dynamically create a (virtual) SiteMap.xml file that Google (and other search engines) can use as a reference when spidering my sites. I thought I'd share the basic implantation as a starting point. Ideally you'd add a property to each EPiServer PageType page for "change frequency" and "priority" which the sitemap generator would then use, but for this basic version I've simply set the homepage to 1.0 (the maximum priority) with a daily change, and all other pages to ... [More]

Tags:

ASP.NET | C# | EPiServer

New module on EPiCode

by Dan Matthews 10. June 2008 12:13
At the EPiServer Partner Summit I was chatting over dinner to Andy Brodie of Networked Planet. He was remarking that it would be nice within EPiServer to have the capability to show site thumbnails when you hovered over hyperlinks. This intrigued me so when I got back to the UK I did some investigation. There are sites on the internet that do provide a service for this, such as websnapr, but ideally I wanted something that I had full control over. Time to start coding :) After some investigation on the web I found a great article about the WebBrowser control and ASP.NET. I tailored it to my ... [More]

Tags:

.NET/C# | EPiServer

EPiServer: Get a Page's Friendly URL

by Brad 9. June 2008 11:33
As part of my Search Engine friendly SiteMap.xml generator (using a HttpHandler - expect a blog post shortly...) I needed to output the friendly URL for each page in the site. However a call to PageData.LinkURL returns the actual link to the page (example shown below), not a "friendly" one that gets displayed in the browser address bar, or in any Hyperlink within the site. /MySite/Default.aspx?id=26&epslanguage=en-GB I had a look through the EPiServer documentation and couldn't find anything obvious so resorted to creating my own method to do it (shown below). Simply pass the rele... [More]

Tags:

ASP.NET | C# | EPiServer

C#: Google Map Server Control - Part 2 - Custom EPiServer Property

by Brad 9. June 2008 09:24
This post tells you how to take what I discussed in Part 1 and turn it into a custom EPiServer property, so CMS user's can simply enter a postcode and it will call of to Google's Local Search API, return the Coordinates for the postcode and plot a marker on the map. The user can then drag the marker for a more exact location, set the zoom level and finally the type of map (Normal, Satellite or Hybrid). The data is then rendered on the public site using the code from Part 1. The screenshot below show's how it will look in EPiServer (click the thumbnail for the full size version): Creating a... [More]

Tags:

ASP.NET | ASP.NET AJAX | C# | EPiServer

C#: Google Map Server Control - Part 1

by Brad 6. June 2008 15:17
Following on from my Google Analytics server control, I wanted make something "cooler", so creating a Server Control to render a Google Map control seemed ideal. Part 1 covers the creation of the this control, stay tuned for part 2 which will focus on creating a custom EPiServer property so it can be used in the EPiServer edit area, featuring Geocoding to lookup the coordinates from a UK post code, Map type selection and zoom level. Anyway here's the generic bit that can be used on any site... First off we need a set of basic properties to hold Latitude, Longitude, Zoom Level and Map Type: ... [More]

Tags:

ASP.NET | ASP.NET AJAX | C# | EPiServer

CompareValidator isn't working with more than 2 decimal places for Currency data-types

by Dominic Zukiewicz 5. June 2008 14:52
I used a ASP .NET CompareValidator to validate a floating point amount in a textbox. While testing the application, I noticed that "0.05" would work, but "0.052", "0.0521", "0.05213" wouldn't? They were all valid numbers, but for some reason the validator was saying it wasn't? Its turns out that theconfigured Currency data-type only allows the regional default of decimal places. Since the Regional Settings was for UK and the decimal places were 2, it wasn't technically a valid currency over 2 decimal places. Instead I used the Double data-type to validate against, and then cast that to a de... [More]

Tags:

Retrieve the time elapsed in C# with the StopWatch class

by Dominic Zukiewicz 5. June 2008 09:57
When doing some performance testing, I used to use the DateTime and TimeSpan classes to retrieve the time elapsed - similar to this example: public static void PerformLongOperation(){ DateTime start = DateTime.Now;   //Long running operation Thread.Sleep(1500);   DateTime end = DateTime.Now; TimeSpan elapsedTime = end - start; Console.WriteLine("Operation took {0:F2} seconds to complete.", elapsedTime.TotalSeconds);} Okay, so its not THAT bad is it really. So lets just check what happens when the measurement is very minute:   public static void P... [More]

Tags:

Framework

C#: Google Analytics Server Control

by Brad 4. June 2008 11:20
Today I've been consolidating UserControls that I've found myself using in one EPiServer project after another into a nice Server Control library. One such control that gets used on every site (even non-EPiServer ones) is one which adds the Google Analytics JavaScript code to the page. I decided this would be the first UserControl to migrate. Firstly I created a constant GoogleAnalyticsJavaScript which holds the JavaScript string to be added to the page. The only change I needed to make was to dynamically add the unique Google Analytics tracking code that was generated specifically for my dom... [More]

Tags:

ASP.NET | C# | EPiServer

C# Register onUnload JavaScript programmatically in code-behind

by Brad 3. June 2008 14:22
Having just created a Google Map server control I spent some time trying to register the relevant unload scripts that the Google API demands. However there was no easy way to get access to the body tag, and I certainly didn't want to have to edit the body tag, adding runat="server" as that would ruin my nicely "wrapped" control, I simply want a developer to drag it out of their Visual Studio Toolbox and it work... So after some thought I tried the following, which worked a treat: //Now we need to add the google maps //ONUNLOAD JavaScript function (it its not be added already) if (!Page... [More]

Tags:

C#

Powered by BlogEngine.NET 1.5.0.7
Theme by Interakting

Interakting

A full service digital agency offering online strategy, design and usability, systems integration and online marketing services that deliver real business benefits and ensure your online objectives are met.

Calendar

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar