 |
"This row already belongs to another table" Error
Paul Marshall (41456 views)
"This row already belongs to another table" Error
#$#<a href="http://www.dotnetkicks.com/kick/?url=http://www.geekzilla.co.uk/View37EB5230-5B79-4D00-800C-52D7A46CFB15.htm"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://www.geekzilla.co.uk/View37EB5230-
|
 |
Launching an Atlas ModalPopupExtender from JavaScript
Paul Hayman (31656 views)
Launching an Atlas ModalPopupExtender from JavaScript
{Looking for an '''Ajax version''' of this article??}http://www.geekzilla.co.uk/View38736C2B-BAD3-418A-A5B0-DAC4F1A5A83A.htm
Looking round the web there are some crazy ways people are trying to launch the ModalPopupExtender from JavaScrip
|
 |
Creating a Tag Cloud in C#
Paul Hayman (25869 views)
Creating a Tag Cloud in C#
I wanted to add a TagCloud to GeekZilla. The first thing I did was look around the web for some examples (or free components). To my supprise none jumped out at me. So, I decided to write my own.
At first I found myself wondering how I would render different size w
|
 |
Authenticated HTTPRequests (Using Credentials)
Dave Howard (18955 views)
Authenticated HTTPRequests (Using Credentials)
#$#<a href="http://www.dotnetkicks.com/kick/?url=http://www.geekzilla.co.uk/ViewC5E6201A-DFC1-4091-8145-5A893504C0E4.htm"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://www.geekzilla.co.uk/ViewC5E6201A-DFC1-
|
 |
IsGuid() (Regular Expression Guid Match)
Paul Hayman (12799 views)
IsGuid() (Regular Expression Guid Match)
A regular expression for validating a string as being a Guid is..
#c#@"^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$"
#c#
Example usage
Below is a function I try to keep handy which tests
|
 |
Why we use C# for .NET development
Dave Howard (11753 views)
Why we use C# for .NET development
#$#<a href="http://www.dotnetkicks.com/kick/?url=http://www.geekzilla.co.uk/View026313AC-108F-4EA1-90A2-5E5BE0DEE0F2.htm"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://www.geekzilla.co.uk/View026313AC-108F-4EA1-90A2-5E
|
 |
Writing CLR Stored Procedures in C#
Paul Hayman (11227 views)
Writing CLR Stored Procedures in C#
As SQL Server 2005 rolls out DBA's are going to be forced to learn either C# or Visual Basic or both. Until now these were client side languages and not knowing them had little impact on your job. And if you write code in these languages your going to have to
|
 |
Adding ATLAS to an Existing Web Application
Mark Page (10938 views)
Adding ATLAS to an Existing Web Application
Recently had to add '''ATLAS''' to an existing ASP.NET 2.0 application and found that there is more to it than simply adding a reference to the Microsoft.Web.Atlas.dll.
I tried registering the assembly in an '''<@ Register>''' tag after adding the
|
 |
Redirect a page using a Header
Paul Marshall (10341 views)
Redirect a page using a Header
Any keen surfer will be familiar with '''Affiliate Marketing''', its a huge industry with '''Google's Adwords''' driving "Pay Per Click" campaigns. '''Google''' provide the '''Adwords''' application and '''Google Analytics''' to track the effectiveness of marketi
|
 |
Using Enum.Parse()
Dave Howard (9797 views)
Using Enum.Parse()
#$#<a href="http://www.dotnetkicks.com/kick/?url=http://www.geekzilla.co.uk/View3C1F25C4-1681-44D6-A34C-133ECC79FA24.htm"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://www.geekzilla.co.uk/View3C1F25C4-1681-44D6-A34C-133ECC79FA24.htm
|
 |
Integrating Dojo Fisheye and SiteMapDataSource
Mark Page (9500 views)
Integrating Dojo Fisheye and SiteMapDataSource
Everybody seems to be getting excited over this AJAX thing. Even Microsoft are (at last... ok they started it with OWA) getting on the bandwagon with the Atlas libraries.
Of course just because Atlas exists doesn't mean you cannot use some other
|
 |
Programmatically resolving ~ URL's to the Virtual Root using ResolveURL()
Paul Hayman (8432 views)
Programmatically resolving ~ URL's to the Virtual Root using ResolveURL()
It's common knowledge that a control, when '''Runat="server"''' will resolve it's src or href attribute to a virtual root when the URL starts with '''~/'''
For example:
#h#<a href="~/Customers/Profile.aspx" Runat="serv
|
 |
Comparing ATLAS and Dojo (part 1)
Mark Page (8283 views)
Comparing ATLAS and Dojo (part 1)
This is a first article in a series comparing some of the functionality of ATLAS with another popular AJAX framework called Dojo. Both frameworks have some powerfull components and there is a high degree of overlap.
This first article is a straight comparisi
|
 |
CLR Stored Procedure for searching files
Paul Hayman (7348 views)
CLR Stored Procedure for searching files
I was recently asked to write a CLR stored procedure which would process a text file and return a row for each line in the file that contained text matching our search criteria.
I'd never written a CLR stored proc before so it was an interesting learn
|
 |
System tray and balloon tips
Dave Howard (7312 views)
Balloon Tips from the System Tray
You can really easily add system tray function to .NET windows forms by dragging the NotifyIcon object onto your form.
You can then use this to display balloon tips from the system tray with the code below:
#c#myNotifyIcon.ShowBalloonTip(500, "Title", "Ti
|
 |
Triple DES encryption wrapper
Paul Hayman (7108 views)
Triple DES encryption wrapper
Here is a handy wrapper for Triple DES encryption:
#c#using System;
#c#using System.Collections.Generic;
#c#using System.Text;
#c#using System.Security.Cryptography;
#c#using System.IO;
#c#
#c#namespace Security
#c#{
#c# /// <summary>
#c# /// Wrap
|
 |
Extending web.sitemap
Mark Page (7011 views)
Extending web.sitemap
If you are using '''ASP.NET''' you are probably already familiar with the new sitemap components.
The '''sitemapdatasource''' and '''web.sitemap''' elements make it very easy to build and maintain rich site structures.
Using the '''Eval''' statement and recursing acr
|
 |
Serializing abstract classes to XML
Dave Howard (6767 views)
Serializing abstract classes to XML
Digg it: http://digg.com/programming/Serializing_abstract_classes_to_XML_in_c
It is often useful to have abstract classes with several derived types to allow use of strongly typed lists and the such.
For example you might have a DocumentFragment class w
|
 |
Could not write to output file ... The directory name is invalid
Paul Hayman (6554 views)
Could not write to output file ... The directory name is invalid
Recently had a problem deploying an app to a fresh 2003 server. Basically, the application wouldn't start, instead we recieved an error stating that the compiler couldn't write to the '''"Temporary ASP.NET Files"''' folder because
|
 |
Auto-complete using ATLAS
Dave Howard (5957 views)
Auto-complete using ATLAS
#$#<a href="http://www.dotnetkicks.com/kick/?url=http://www.geekzilla.co.uk/View7585D539-C094-4211-9FFC-32FABE4D09B5.htm"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://www.geekzilla.co.uk/View7585D539-C094-4211-9FFC-32FABE4D09B
|
 |
Restricting the number of rows in a dataview when binding to a repeater
Paul Hayman (5771 views)
Restricting the number of rows in a dataview when binding to a repeater
The problem
I needed to restrict the number of items bound to an '''asp:repeater'''. Basically I never wanted more than 10 items to be displayed.
Options
The right thing to do would be to restrict the number of it
|
 |
Sorting an XML document in C# using XSL
Paul Hayman (5388 views)
Sorting an XML document in C# using XSL
I needed to sort some XML in C# before itterating through the document. In the end I used the XslCompiledTransform to apply an XSL stylesheet to the XML document. Works very quickly. For reference, this is how I did it.
The code
The following uses
|
 |
Reading a file which is locked by another process
Paul Hayman (5074 views)
Reading a file which is locked by another process
The following code snippet shows how to read a file which is locked by another process..
#c#FileStream logFileStream = new FileStream("c:\test.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
#c#StreamReader logFileReader = new S
|
 |
Web service calls from javascript using ATLAS (part 2) - Complex return types
Dave Howard (4972 views)
Web service calls from javascript using ATLAS (part 2) - Complex return types
#$#<a href="http://www.dotnetkicks.com/kick/?url=http://www.geekzilla.co.uk/ViewF266ADEB-8F62-4E92-8036-1D2436C2DE3A.htm"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://www.g
|
 |
Encoding string to Base64 / UTF8
Dave Howard (4296 views)
Encoding string to Base64 / UTF8
Sometimes you need to convert strings to Base64, for example in security components. The function below does this:
#c#public string stringToBase64(string s)
#c#{
#c# try
#c# {
#c# byte[] bytes = new byte[s.Length];
#c# bytes = Syste
|
 |
Returning a value from a PageMethod
Paul Hayman (4220 views)
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
|
 |
Web service calls from javascript using ATLAS (part 1)
Dave Howard (3973 views)
Web service calls from javascript using ATLAS (part 1)
#$#<a href="http://www.dotnetkicks.com/kick/?url=http://www.geekzilla.co.uk/View91E6FCCB-DB0A-499C-A2CC-9854452D2086.htm"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://www.geekzilla.co.uk/View91E6FC
|
 |
Custom Templated SiteMap Navigator Control
Paul Hayman (3870 views)
Custom Templated SiteMap Navigator Control
After discovering the power of the SiteMap, especially when linked to Authentication, it wasn't long before binding the TreeView to the map was not enough.
I needed to have total control over what was displayed to the user for each item, so I wrote
|
 |
Remembering position of DragOverlayExtender with Profile
Paul Hayman (3653 views)
Remembering position of DragOverlayExtender with Profile
You can get Atlas to store the last known position of your floating panel in the profile.
Three things you need to do to get this to work.
ProfileScriptService
In the page with the DragOverlayExtender you'll need to add a atlas
|
 |
Extending Strongly Typed Datasets
Dave Howard (3486 views)
Extending Strongly Typed Datasets
Strongly Typed Datasets are a rather nice addition to VS2005 (they don't lend themselves well to acronyms however)
You still need to create a database and tables and realationships but using STDs saves a writing huge amount of code.
If this code were gene
|
 |
Web service calls from javascript using ATLAS (part 3) - Complex properties
Dave Howard (3405 views)
Web service calls from javascript using ATLAS (part 3) - Complex properties
#$#<a href="http://www.dotnetkicks.com/kick/?url=http://www.geekzilla.co.uk/View7DA902AA-513E-48D2-AD02-0F1A1946A999.htm"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://www.gee
|
 |
Programmatically adding LINKs to HTML HEADER in Code Behind
Paul Hayman (3181 views)
Programmatically adding LINKs to HTML HEADER in Code Behind
In this example I am adding a link to the html header pointing to an rss feed.
#c#HtmlLink link = new HtmlLink();
#c#link.Attributes.Add("type", "application/rss+xml");
#c#link.Attributes.Add("rel", "alternate");
#c#link.Attribut
|
 |
Using Regex.Replace
Paul Hayman (3122 views)
Using Regex.Replace
Say you want to get the username from a fully qualified username such as '''MyDomain\AUser'''
Most developers would turn to SubString and LastIndexOf functions .. for example
#c#string userName = @"MyDomain\AUser";
#c#string result = userName.SubString(userName.LastInde
|
 |
EasyHTTP
Barrington Haynes (2960 views)
EasyHTTP
EasyHTTP is a simple class which exposes the HTTP functionality of .NET as a number of simpler methods.
#c#using System;
#c#using System.Data;
#c#using System.Configuration;
#c#using System.Web;
#c#using System.Web.Security;
#c#using System.Web.UI;
#c#using System.Web.UI.WebCo
|
 |
Updating controls from another thread
Dave Howard (2842 views)
Updating form controls from another thread.
Form controls, by default, can only be updated by the forms thread. Otherwise an invoke must be used.
The example below shows a simple logging function that can be called by threads other than the forms.
#c#delegate void LogSafeCall(string s);
|
 |
Getting the Virtual Path of a Request in c#
Paul Hayman (2799 views)
Getting the Virtual Path of a Request in c#
This simple bit of code will get you the '''Virtual Path''' of your current request.
#c#public static string GetVirtualPath(string url)
#c#{
#c# if (HttpContext.Current.Request.ApplicationPath == "/")
#c# {
#c# return "~" + url;
#
|
 |
The null coalescing operator: ??
Paul Hayman (2174 views)
The null coalescing operator: ??
This is a new feature of c# 2.0. The null coalescing operator is a short cut for checking if a value is null and if so returning the value of the second operand. Kind of like an IIF. The syntax is as follows:
#c#string newValue = someValue ?? "default";
|
 |
Assigning an array of strings to a variable
Paul Hayman (2042 views)
Assigning an array of strings to a variable
Declaring a string array with hard coded data is easy.
#c#string[] newString = new string[] {"one", "two", "three"}
Passing hard coded array into method
Likewise, passing an array of hard coded data into a method is also easy..
For example
|
 |
Generating a resized image with maximum image quality
Paul Hayman (1559 views)
Generating a resized image with maximum image quality
Here's some code I use for generating a resized image with no Jpeg compression.
#c#public MemoryStream GetResized(Bitmap originalImage, int width, int height)
#c#{
#c# System.Drawing.Image outputImage;
#c# MemoryStream outputStre
|
 |
Convert to and from Hex
Paul Hayman (1395 views)
Convert to and from Hex
Convert from an int to Hex
#c#String result = String.Format("{0:x2}", 255)
Convert from Hex to an int
#c#int result = int.Parse("FF", System.Globalization.NumberStyles.HexNumber);
|
 |
Fixing Form Action on UrlRewrite (UrlRewriter)
Paul Hayman (1287 views)
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 a
|
 |
Using a .Net 2.0 anonymous delegate when generating a thumbnail
Paul Hayman (1219 views)
Using a .Net 2.0 anonymous delegate when generating a thumbnail
Rather than using a mehod which does nothing except return false. Use a .Net 2.0 anonymous delegate for the GetThumbnailImageAbort parameter.
#c#delegate() { return false; }
Example
#c#System.Drawing.Image thumbResult = t
|
 |
Set Input Focus on a Control Programatically Added to an ASP.Net Page
Paul Marshall (1194 views)
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
|
 |
Title Case
Danny Mehmed (166 views)
Whilst returning some data from LDAP, I found that it was returning in Upper Case, I needed it to be in Title case format.
I found this method of converting to title case
Title Case converts every first letter of a word in a sentence to upper case, and the rest to lower case.
Of course yo
|