<?xml version="1.0" encoding="UTF-8"?>
<entries type="array">
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Here I will summarize some quick points about using the WCF Rest Starter Kit P2 to consume REST services. If you are not familiar with it, here is a good article from msdn: &lt;a href="http://msdn.microsoft.com/en-us/library/ee391967.aspx"&gt;http://msdn.microsoft.com/en-us/library/ee391967.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
// quick code example .net accessing shopify api
private orders InitialOrderSync(string appURL, string apiKey, string pwd)
		{
// note here we can use http or https
			HttpClient client = new HttpClient("https://" + appURL);
// set optional credentials
			client.TransportSettings.Credentials = new NetworkCredential(apiKey, pwd);
			// the uri of the REST path to get, can also pass in parameters 
			HttpResponseMessage message = client.Get("admin/orders.xml");
			message.EnsureStatusIsSuccessful(); // make sure all ok
                        // serialize into object
			orders shopifyOrders = message.Content.ReadAsXmlSerializable&lt;orders&gt;();
			return shopifyOrders;
		}
&lt;/pre&gt;
&lt;p&gt;
You may be wondering how did I build the orders object based on the xml. This is very easy. Just copy the xml you will be serializing from start to finish, go into Visual Studio that has wcf rest kit installed, add a new Class, and go menu Edit -&gt; Paste as XML Types. That's it.
&lt;/p&gt;
&lt;p&gt;
As far as using requirements, add references to your project to all 3 binaries in the WCF REST kit installation directory folder.&lt;br /&gt; in your code you'll need these guys for above to work:&lt;br/&gt;&lt;br/&gt;
using System.Xml.Serialization;
using System.Xml;
using System.Runtime.Serialization;
using Microsoft.Http;
using Microsoft.ServiceModel;
using System.Net;
&lt;/p&gt;</content>
    <created-at type="datetime">2010-03-05T16:13:29-08:00</created-at>
    <id type="integer">66</id>
    <title>WCF REST Starter Kit Consumer quick example</title>
    <updated-at type="datetime">2010-03-05T16:19:56-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">5</category-id>
    <content>&lt;p&gt;After some research looking for a good jquery password strength meter, I found one that I liked, looked good, and was easy to use. It is also a jquery plugin, which makes it easier to implement.&lt;/p&gt;
&lt;p&gt;
Here is the link: &lt;a href="http://mypocket-technologies.com/jquery/password_strength/"&gt;SelectBox Password Strength Plugin&lt;/a&gt;
&lt;/p&gt;</content>
    <created-at type="datetime">2010-02-25T21:10:21-08:00</created-at>
    <id type="integer">65</id>
    <title>JQuery Password Strength</title>
    <updated-at type="datetime">2010-02-25T21:10:21-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Here is an example of having page properties that hold their value in viewstate so that when the same screen posts back but in a different mode, ie. multistep processes, you can still hold the value.
Also note we put the value into a local variable as well, because the viewstate will only be set after the postback, so therefore if you tried to access the property in the same request, you won't get a null back.
&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
public partial class WizardSignup : System.Web.UI.Page
	{
public int? PhysicalDockId
		{
			get
			{
				if (ViewState["PhysicalDockId"] == null &amp;&amp; _physicalDockId == null)
					return null;
				else
				{
					return _physicalDockId ?? (int)ViewState["PhysicalDockId"];
				}
			}
			set
			{
				ViewState["PhysicalDockId"] = (_physicalDockId = value);
			}
		}
		private int? _physicalDockId = null;
}
&lt;/pre&gt;</content>
    <created-at type="datetime">2010-02-25T11:55:03-08:00</created-at>
    <id type="integer">64</id>
    <title>Page Properties with Viewstate done right</title>
    <updated-at type="datetime">2010-02-25T11:56:41-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">6</category-id>
    <content>&lt;p&gt;Some of the Telerik controls offer a Culture property setting. Here is a list of what these can be set to. &lt;/p&gt;
&lt;a href="http://www1.cs.columbia.edu/~lok/csharp/refdocs/System.Globalization/types/CultureInfo.html"&gt;System.Globalization Cultures list&lt;/a&gt;
&lt;p&gt;This is useful for example in the RadDatePicker control, to be able to change the date format string, ie. using european standards that use the day-month-year order. You would set the Culture property to "en-GB" for example to achieve this.&lt;/p&gt;
&lt;p&gt;Telerik controls that use this:
RadCalendar  	CultureInfo&lt;br/&gt;
RadDatePicker 	Culture&lt;br/&gt;
RadTimePicker 	Culture&lt;br/&gt;
RadDateTimePicker Culture&lt;br/&gt;
&lt;/p&gt;</content>
    <created-at type="datetime">2010-02-19T15:02:41-08:00</created-at>
    <id type="integer">63</id>
    <title>Globalization Culture Property list</title>
    <updated-at type="datetime">2010-02-19T15:03:36-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Here is a basic example of a custom exception that can have the message property assigned to.&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
public class PresentationException : Exception, ISerializable
	{
		public override string Message
		{
			get
			{
				return _message;
			}
		}
		private string _message;

		public PresentationException()
		{

		}
		public PresentationException(string message)
		{
			_message = message;
		}
		public PresentationException(string message, Exception inner)
		{
			_message = message;
		}

		// This constructor is needed for serialization.
		protected PresentationException(SerializationInfo info, StreamingContext context)
		{
		}
	}
&lt;/pre&gt;</content>
    <created-at type="datetime">2010-02-18T16:06:22-08:00</created-at>
    <id type="integer">62</id>
    <title>Custom Exception that processes Message</title>
    <updated-at type="datetime">2010-02-18T16:07:06-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Sometimes we want to show a custom message in a page's validation summary depending on something that happens in our business object, ie. catch an exception and display the message to the user.&lt;/p&gt;
&lt;p&gt;First, be sure your ValidationSummary is in a Panel control. You can add the following presentation helper somewhere in your project. Basically we pass in the message we want to be displayed, ie the Exception.Message and this function will return a custom validator that we add to the Panel that contains the validation summary.&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
public static class PresentationHelper
	{
		public static CustomValidator BuildCustomValidator(string message)
		{
			CustomValidator CustomValidatorCtrl = new CustomValidator();
			CustomValidatorCtrl.IsValid = false;
			CustomValidatorCtrl.ErrorMessage = message;
			CustomValidatorCtrl.Display = ValidatorDisplay.None;
			return CustomValidatorCtrl;
		}
	}
&lt;/pre&gt;

&lt;p&gt;Here is an example of usage in a Page codebehind:&lt;/p&gt;

&lt;pre name="code" class="csharp"&gt;
protected void ButtonCreate_Click(object sender, EventArgs e)
{
     try
     {
          MyBusinessObject.DoSomething(...);
     }
     catch(Exceptions.PresentationException exc)
     {
          PanelCreate.Controls.Add(PresentationHelper.BuildCustomValidator(exc.Message));
     }
}
&lt;/pre&gt;</content>
    <created-at type="datetime">2010-02-18T15:53:11-08:00</created-at>
    <id type="integer">61</id>
    <title>Validation Summary Custom Message</title>
    <updated-at type="datetime">2010-02-18T15:57:12-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;This is useful to get the user ID object that a user is represented by in the database. It is the providerKey property of the Membership user object. Note that it comes back as an object and then you need to cast it usually to a Guid or sometimes an int, depending on your database schema and Membership provider.&lt;/p&gt;

&lt;pre name="code" class="csharp"&gt;
// note you may want to check if the Membership.GetUser() is null before accessing properties.
Guid userId = (Guid)Membership.GetUser().ProviderUserKey;
&lt;/pre&gt;</content>
    <created-at type="datetime">2010-02-17T18:01:37-08:00</created-at>
    <id type="integer">60</id>
    <title>Membership get user Id</title>
    <updated-at type="datetime">2010-02-17T18:03:32-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">6</category-id>
    <content>&lt;p&gt;Very easy to do, I never though it was possible. Simply add the GroupingSettings CaseSensitive="false" in the rad grid.&lt;/p&gt;
&lt;pre name="code" class="xml"&gt;
  &lt;GroupingSettings CaseSensitive="false"&gt;&lt;/GroupingSettings&gt;
&lt;/pre&gt;</content>
    <created-at type="datetime">2010-02-11T17:35:23-08:00</created-at>
    <id type="integer">59</id>
    <title>RadGrid Filter case insensitive</title>
    <updated-at type="datetime">2010-02-11T17:36:35-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;The default String.Replace is not case Insensitive, here is a quick extension method you could add to get a String.ReplaceCI that would do this. I like extension methods.
&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
public static class StringExtensions
	{
		public static string ReplaceCI(this String sourceString, string searchString, string replaceString)
		{
			if (searchString == null) throw new ArgumentNullException("searchString");
			if (replaceString == null) throw new ArgumentNullException("replaceString");
			StringBuilder retVal = new StringBuilder(sourceString.Length);

			int ptr = 0, lastPtr = 0;

			while (ptr &gt;= 0)
			{
				ptr = sourceString.IndexOf(searchString, ptr, StringComparison.OrdinalIgnoreCase);

				int strLength = ptr - lastPtr;
				if (strLength &gt; 0 || ptr == 0)
				{
					if (ptr &gt; 0)
						retVal.Append(sourceString.Substring(lastPtr, strLength));

					retVal.Append(replaceString);
					ptr += searchString.Length;
				}
				else
					break;

				lastPtr = ptr;
			}

			if (lastPtr &gt;= 0) 
				retVal.Append(sourceString.Substring(lastPtr));

			return retVal.ToString();
		}
}
&lt;/pre&gt;

&lt;p&gt;Ideas were borrowed from this guy: &lt;a href="http://www.yortondotnet.com/2009/07/case-insensitive-string-replace.html"&gt;Case Insensitive String &lt;/a&gt;
&lt;/p&gt;</content>
    <created-at type="datetime">2010-02-10T18:08:16-08:00</created-at>
    <id type="integer">58</id>
    <title>Case Insensitive String Extension Method</title>
    <updated-at type="datetime">2010-02-10T18:10:24-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;
If you use the Repeater a bit, you'll notice it does not have a EmptyRows template, which is kind of lame. I don't know why Telerik hasn't built their own cool repeater which would be quite useful. Anyways, to show an empty message when the row count is zero, add an OnItemDatabound event, and check the Repeater1.Items.Count == 0. If so, you can show hide some label. Below is some sample code, using the Footer in the repeater for your empty message.
&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
protected void RepeaterUpcomingReservations_ItemDataBound(object sender, RepeaterItemEventArgs e)
		{
			if (RepeaterUpcomingReservations.Items.Count == 0)
			{
				if (e.Item.ItemType == ListItemType.Footer)
				{
					Label lblFooter = (Label)e.Item.FindControl("LabelEmpty");
					lblFooter.Visible = true;
				}
			}
		}
&lt;/pre&gt;</content>
    <created-at type="datetime">2010-02-10T18:02:40-08:00</created-at>
    <id type="integer">57</id>
    <title>Empty Data display for asp net Repeater</title>
    <updated-at type="datetime">2010-02-10T18:03:06-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;
This is very easy to do: Simply wrap the text boxes and default button in an ASP Panel control. Then set the DefaultButton property to the ID of the button that should be attached to the Enter key. That's it.
&lt;/p&gt;</content>
    <created-at type="datetime">2010-02-10T16:22:24-08:00</created-at>
    <id type="integer">56</id>
    <title>Default Enter Key Button</title>
    <updated-at type="datetime">2010-02-10T16:22:24-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">6</category-id>
    <content>&lt;p&gt;Sometimes on display, when we have fields that may contain long text, we want to truncate the max length that is displayed on screen. It is easy to do this. First change the column into a Template, then when binding call a function you define.&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
// put this method in your code behind
protected string TruncateString(object stringToValidate)
		{
			string output = Convert.ToString(stringToValidate);
			
			if (output.Length &gt; 30)
			{
				return output.Substring(0, 30) + "...";
			}
			else
			{
				return output;
			}
		}
&lt;/pre&gt;
&lt;p&gt;Now in your template in the RadGrid, simply do this when outputting the text: &lt;br/&gt;
&lt;b&gt;TruncateString(Eval("PartnerNotes"))&lt;/b&gt; &lt;/p&gt;</content>
    <created-at type="datetime">2010-02-05T15:10:10-08:00</created-at>
    <id type="integer">55</id>
    <title>Truncate String in RadGrid or GridView</title>
    <updated-at type="datetime">2010-02-05T15:43:12-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;To limit users and roles to different folders it is pretty easy. First make sure you have your membership and role providers configured and working ok. Then edit the web.config.
Microsoft has a perfect article here: &lt;a href="http://msdn.microsoft.com/en-us/library/8aeskccd.aspx"&gt;deny elements for authorization&lt;/a&gt;
&lt;/p&gt;
&lt;pre name="code" class="xml"&gt;
// this example will limit access to folder Admin to only admin role users.
// note the order is important, if not won't work.
&lt;location path="Admin"&gt;
	&lt;system.web&gt;
		&lt;authorization&gt;
			&lt;allow roles="admin"&gt;&lt;/allow&gt;
			&lt;deny users="*"&gt;&lt;/allow&gt;
		&lt;/authorization&gt;
	&lt;/system.web&gt;
&lt;/location&gt;
&lt;/pre&gt;</content>
    <created-at type="datetime">2010-01-22T10:15:39-08:00</created-at>
    <id type="integer">54</id>
    <title>Allow deny users and roles web.config</title>
    <updated-at type="datetime">2010-01-22T10:22:52-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">6</category-id>
    <content>&lt;p&gt;With Telerik RadGrid, when you hit the &lt;span&gt;Add New Record&lt;/span&gt; and the editable form comes up, the first textbox or dropdown is not selected focused by default. This code will do this. Attaches to Behavior: ItemDataBound&lt;/p&gt;

&lt;pre name="code" class="csharp"&gt;
protected void RadGridServiceTypes_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
		if (e.Item is Telerik.Web.UI.GridEditableItem &amp;&amp; e.Item.IsInEditMode)
		{
			Telerik.Web.UI.GridEditableItem form = (Telerik.Web.UI.GridEditableItem)e.Item;
			TextBox comboBox = (TextBox)form["ServiceName"].Controls[1];
			comboBox.Focus();
		}
}
&lt;/pre&gt;</content>
    <created-at type="datetime">2010-01-20T13:02:41-08:00</created-at>
    <id type="integer">53</id>
    <title>Focus Grid Edit Item on Insert or Edit</title>
    <updated-at type="datetime">2010-01-20T13:04:22-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;
This is pretty easy once you know what you are doing:&lt;br/&gt;
&lt;pre name="code" class="csharp"&gt;
DateTime newYorkTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindTimeZoneById("US Eastern Standard Time"));
&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;
BTW it is a good idea to keep times in the database in UTC that way it is easy to convert using above.
&lt;/p&gt;</content>
    <created-at type="datetime">2010-01-15T23:26:10-08:00</created-at>
    <id type="integer">52</id>
    <title>Convert DateTime TimeZone from UTC</title>
    <updated-at type="datetime">2010-01-15T23:26:50-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;
Great article on msdn on how to do this: &lt;a href="http://msdn.microsoft.com/en-us/library/cc668201.aspx"&gt;http://msdn.microsoft.com/en-us/library/cc668201.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;If you are using &lt;b&gt;Session&lt;/b&gt; in your code that is routed to, you will need to add this line to your web.config under system.webserver -&gt; modules - &lt;br /&gt;&lt;br/&gt;
&lt;pre name="code" class="xml"&gt;
&lt;system.webServer&gt;
&lt;modules runAllManagedModulesForAllRequests="true"&gt;
    your other stuff in here
&lt;/modules&gt;
&lt;/system.webServer&gt;
&lt;/pre&gt;
&lt;/p&gt;</content>
    <created-at type="datetime">2009-12-16T15:29:42-08:00</created-at>
    <id type="integer">51</id>
    <title>Configuring ASP .NET Routing</title>
    <updated-at type="datetime">2009-12-16T15:31:31-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">5</category-id>
    <content>&lt;p&gt;We often have variable width objects in a page, like Buttons or images that we need to center. I came across this article that explains it well: &lt;a href="http://www.tightcss.com/centering/center_variable_width.htm"&gt;Centering Variable Width Content&lt;/a&gt;
&lt;/p&gt;</content>
    <created-at type="datetime">2009-12-11T11:08:11-08:00</created-at>
    <id type="integer">50</id>
    <title>CSS Center Variable Width Div</title>
    <updated-at type="datetime">2009-12-11T11:08:11-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;
Here is an article that explains how to add validators to the columns for in place editing.
Basically on item created event we are programatically adding a validator behind the textbox.
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.telerik.com/help/aspnet-ajax/grdvalidation.html"&gt;Grid Validation&lt;/a&gt;
&lt;/p&gt;</content>
    <created-at type="datetime">2009-12-07T11:54:27-08:00</created-at>
    <id type="integer">49</id>
    <title>Telerik RadGrid In Place Edit Validation</title>
    <updated-at type="datetime">2009-12-07T11:54:27-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;For use with the Telerik RadUpload COntrol. This shows how to quickly process an uploaded file in codebehind so you get it into a byte array ready to be put in the database.
&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
protected void ButtonUpload_Click(object sender, EventArgs e)
{
    if (RadUpload1.UploadedFiles.Count &gt; 0)
    {
        string filename = RadUpload1.UploadedFiles[0].FileName;
	int length = (int)RadUpload1.UploadedFiles[0].InputStream.Length;
	byte[] bytes = new byte[length];
	RadUpload1.UploadedFiles[0].InputStream.Read(bytes, 0, length);
        
        // Now simply call your Data Model function to create item, bytes contains data
        CreateFile(filename, bytes, RadUpload1.UploadedFiles[0].ContentType);
    }
}

&lt;/pre&gt;</content>
    <created-at type="datetime">2009-12-01T13:33:44-08:00</created-at>
    <id type="integer">48</id>
    <title>Telerik RadUpload how to get bytes</title>
    <updated-at type="datetime">2009-12-01T13:37:16-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;If you have a function that returns a value and is called by an ObjectDataSource, ie Insert or Update, you can use this to get the returned value from the function&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
// define the OnInserted function of the object data source in the aspx side.

protected void ObjectDataSourceProduct_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
{
	ProductId = (int)e.ReturnValue;
	Response.Redirect("EditProduct.aspx?productId=" + ProductId.ToString());
}

&lt;/pre&gt;</content>
    <created-at type="datetime">2009-11-20T17:34:19-08:00</created-at>
    <id type="integer">47</id>
    <title>Get Returned object from ObjectDataSource</title>
    <updated-at type="datetime">2009-11-20T17:53:23-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;
This comes in really handy if you have a class object that has constructors that take in parameters. Basically you will define the ObjectCreating event of the object data source and instantiate your object there, setting the constructor parameters and then set e.ObjectInstance to your object.&lt;/p&gt;
&lt;p&gt;
An example here: &lt;a href="http://www.devtoolshed.com/content/objectdatasource-typename-constructor-parameters"&gt;http://www.devtoolshed.com/content/objectdatasource-typename-constructor-parameters&lt;/a&gt;
&lt;/p&gt;</content>
    <created-at type="datetime">2009-11-16T16:07:55-08:00</created-at>
    <id type="integer">46</id>
    <title>ObjectDataSource Bound to object with Constructor Parameters</title>
    <updated-at type="datetime">2009-11-16T16:09:35-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;To set the mode in which IE8 renders add the following tag to the top of the head section, above the title tag:&lt;/p&gt;
&lt;pre name="code" class="xml"&gt;
&lt; meta http-equiv="X-UA-Compatible" content="IE=edge" /&gt;

&lt;/pre&gt;

&lt;p&gt;This will get rid of the option on IE8 to view the page in compatibility mode, so that if your page is optimized for IE8, or newer browsers, users won't screw it up by clicking on compatibility mode.&lt;/p&gt;
&lt;p&gt;For more info and to set up in IIS via web.config go here: http://msdn.microsoft.com/en-us/library/cc288325%28VS.85%29.aspx&lt;/p&gt;</content>
    <created-at type="datetime">2009-11-11T17:45:26-08:00</created-at>
    <id type="integer">45</id>
    <title>IE8 force render in IE8 mode</title>
    <updated-at type="datetime">2009-11-11T17:54:26-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Extension Methods can be pretty cool, but you should watch out what you use them for. They are used to extend existing classes, like the String or int class. In this example I will show a quick Truncate extension to the String class so you could simply go myString.Truncate(30)
&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
public static class MyExtensions
{
     public static string Truncate(this String str, int maxLength)
     {
         if (str.Length &gt; maxLength)
         {
	     str = str.Substring(0, maxLength);
	 }
         return str;
     }
}
// usage
String car = "pedoloco";
car.Truncate(3); // ped
car.Truncate(100); // pedoloco   
&lt;/pre&gt;</content>
    <created-at type="datetime">2009-11-05T17:20:03-08:00</created-at>
    <id type="integer">44</id>
    <title>Extension Methods, ie String.Truncate</title>
    <updated-at type="datetime">2009-11-05T17:22:29-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Sql methods are a neat tool inside of linq. They allow you to do typical functions we are used to from sql but nicely built into linq. They are found under: using System.Data.Linq.SqlClient;
&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
// Example where dc is DataContext
var query = from u in dc.Users
            where SqlMethods.Like(u.UserName, "%johnny%")
            select u;
&lt;/pre&gt;
</content>
    <created-at type="datetime">2009-11-05T15:34:43-08:00</created-at>
    <id type="integer">43</id>
    <title>Linq Like SqlMethods</title>
    <updated-at type="datetime">2009-11-05T15:36:26-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;I can never remember how to format a Datetime object into a particular looking string. Here is an article that nicely shows how to do this:&lt;/p&gt;
&lt;a href="http://www.csharp-examples.net/string-format-datetime/"&gt;http://www.csharp-examples.net/string-format-datetime/&lt;/a&gt;
&lt;br /&gt;</content>
    <created-at type="datetime">2009-11-03T14:16:44-08:00</created-at>
    <id type="integer">42</id>
    <title>Date Formatting To String</title>
    <updated-at type="datetime">2009-11-03T14:16:44-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;The Remember Me functionality of the login control in asp.net does not work out of the box for some reason. You have to manually override it.&lt;/p&gt;
&lt;p&gt;Here is a good forum post that clearly explains it, scroll down to the post by "mokeefe":&lt;br /&gt;
&lt;a href="http://forums.asp.net/p/1087450/2571221.aspx#2571221"&gt;http://forums.asp.net/p/1087450/2571221.aspx#2571221&lt;/a&gt;
&lt;/p&gt;</content>
    <created-at type="datetime">2009-10-29T11:05:06-07:00</created-at>
    <id type="integer">41</id>
    <title>Login Control Remember Me</title>
    <updated-at type="datetime">2009-10-29T11:05:06-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;I found this to be getting me when trying to set up a WCF service that was taking in a big object as a parameter. Even when setting the maxmessagesize in the wcf service config I would still get a weird error about a validation exception. The problem was the request being passed in was too big, so to allow for bigger requests you need to set the below. Note this goes under System.Web in the web.config
&lt;/p&gt;
&lt;pre name="code" class="xml"&gt;
&lt;system.web&gt;
&lt;httpRuntime maxRequestLength="102400"&gt;&lt;/httpRuntime&gt;
&lt;/system.web&gt;
&lt;/pre&gt;</content>
    <created-at type="datetime">2009-10-22T17:26:43-07:00</created-at>
    <id type="integer">40</id>
    <title>Set Max Request Length. WCF MaxMessageSize</title>
    <updated-at type="datetime">2009-10-22T17:28:00-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Code to one way hash a string using SHA1.&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
public static string GenerateSHA1(string input)
{
    byte[] buffer = Encoding.UTF8.GetBytes(input);
    SHA1CryptoServiceProvider cryptoTransformSHA1 = new SHA1CryptoServiceProvider();
    string hash = BitConverter.ToString(cryptoTransformSHA1.ComputeHash(buffer)).Replace("-", "");

    return hash;
}
&lt;/pre&gt;</content>
    <created-at type="datetime">2009-09-08T12:10:54-07:00</created-at>
    <id type="integer">39</id>
    <title>Generate SHA1 Hash from string</title>
    <updated-at type="datetime">2009-09-08T12:13:24-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Getting WCF authentication working is not to hard once you know where things go.&lt;/p&gt;
&lt;p&gt;Start off by creating a new WCF Service Application. Add a class like the following:&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
public class CustomUserNameValidator : UserNamePasswordValidator
{
   public override void Validate(string userName, string password)
   {
   if (null == userName || null == password)
   {
      throw new ArgumentNullException();
   }

// validate username and pass
   DataModelUsersDataContext dc = new DataModelUsersDataContext();
   Vendor vendor = dc.Vendors.FirstOrDefault(t =&gt; t.ServiceUsername == userName &amp;&amp; t.ServicePassword == password);

   if (vendor == null)
   {
      throw new FaultException&lt;SecurityTokenException&gt;(new SecurityTokenException("user or pwd incorrect"), "user or pwd incorrect.");
   }
}
}
&lt;/pre&gt;
&lt;p&gt;Not how it inherits from that validator class. It will automatically pass in the username and password on validate, then you can figure out what to do with. Throw an exception if fails validation.
&lt;/p&gt;
&lt;p&gt;Now have to tell your service to use this custom class. Do this in the web.config:&lt;/p&gt;
&lt;pre name="code" class="xml"&gt;
&lt;system.serviceModel&gt;
...
   &lt;behaviors&gt;
      &lt;serviceBehaviors&gt;
         &lt;behavior name="MyNameSpace.Service1Behavior"&gt;
            &lt;serviceMetadata httpGetEnabled="true" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="True" /&gt;
            &lt;serviceThrottling maxConcurrentCalls="40" maxConcurrentInstances="40" maxConcurrentSessions="40" /&gt;
	    &lt;serviceCredentials&gt;
               &lt;userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyNameSpace.VendorUserNameValidator, MyNameSpace" /&gt;
               &lt;serviceCertificate findValue="ws.internal.mysite.com" x509FindType="FindBySubjectName" storeLocation="LocalMachine" /&gt;
	    &lt;/serviceCredentials&gt;
	  &lt;/behavior&gt;
       &lt;/serviceBehaviors&gt;
   &lt;/behaviors&gt;
&lt;/system.serviceModel&gt;
&lt;/pre&gt;
&lt;p&gt;Note the serviceCredentials entry. That is where we set it to use a custom validator mode and specify the class to use. Also note the serviceCertificate entry. You must use securtiy so be sure to specify a cert. This cert can be self-signed and must be kept in your certificate store on your localmachine. If you are not sure how to register your cert on your localmachine or server there is plenty of documentation online.
&lt;/p&gt;</content>
    <created-at type="datetime">2009-09-02T15:49:45-07:00</created-at>
    <id type="integer">38</id>
    <title>Quick WCF Authentication Howto</title>
    <updated-at type="datetime">2009-09-02T16:01:44-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;
Quick code to process incoming querystrings or other user input, ie textboxes from a string to an int.
&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
int messageId;
if (int.TryParse(Request.QueryString["messageId"], out messageId) == false)
{
    messageId = -1; // default value for messageId, ie to create a new item.
}
&lt;/pre&gt;</content>
    <created-at type="datetime">2009-08-20T11:29:37-07:00</created-at>
    <id type="integer">37</id>
    <title>Properly process user input or QueryStrings as int</title>
    <updated-at type="datetime">2009-08-20T11:30:11-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">7</category-id>
    <content>&lt;p&gt;Animations with storyboards in WPF are cool, but often we need to be able to trigger them to start from cs codebehind. For example, on a button click. Here the animationKey param is the key that is defined in the xaml for your storyboard. &lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
private void StartAnimation(string animationKey)
{
     Storyboard pageViewAnimation = (Storyboard)FindResource(animationKey);
     pageViewAnimation.Begin();
}
&lt;/pre&gt;</content>
    <created-at type="datetime">2009-08-04T15:18:21-07:00</created-at>
    <id type="integer">36</id>
    <title>Begin Storyboard Animation from codebehind</title>
    <updated-at type="datetime">2009-08-04T15:20:29-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">7</category-id>
    <content>&lt;p&gt;Setting the Image.Source property in WPF. Note this is slightly different than in silverlight because it requires an object holding the image data as source.&lt;/p&gt;

&lt;pre name="code" class="csharp"&gt;

private void SetPageViewImage(string sourceFile)
{
	Uri uri = new Uri(sourceFile, UriKind.Relative);
	ImageSource imgSource = new BitmapImage(uri);
	PageViewImage.Source = imgSource;
	PageViewImage.Visibility = Visibility.Visible; //optional
}
&lt;/pre&gt;</content>
    <created-at type="datetime">2009-08-04T12:32:32-07:00</created-at>
    <id type="integer">35</id>
    <title>Set Image Source in WPF</title>
    <updated-at type="datetime">2009-08-06T11:04:16-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Sending email is pretty easy in dot net. You want to be sure you are using the 2.0+ &lt;span&gt;System.Net.Mail&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Scott Gu Does a good job in his blog: &lt;a href="http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx"&gt;http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx&lt;/a&gt;
&lt;/p&gt;</content>
    <created-at type="datetime">2009-07-22T17:27:03-07:00</created-at>
    <id type="integer">34</id>
    <title>Sending Email</title>
    <updated-at type="datetime">2009-07-22T17:27:03-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;
It is pretty easy to check the length of a textbox using a regular expression validator.
Simply set the ValidationExpression="[\s\S]{6,15}" and that's it. Note the 6,15 mean min,max, ie. 6 chars min and 15 chars max.&lt;br /&gt;
This can be useful for &lt;span&gt;Password Validation&lt;/span&gt; and similar.
&lt;/p&gt;

&lt;pre name="code" class="xml"&gt;
&lt;asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="NewPassword" ErrorMessage="Wrong Length" SetFocusOnError="True" ValidationExpression="[\s\S]{6,15}"&gt;Must be btw 6 and 15 characters&lt;/asp:RegularExpressionValidator&gt;
&lt;/pre&gt;</content>
    <created-at type="datetime">2009-07-21T12:30:42-07:00</created-at>
    <id type="integer">33</id>
    <title>Regular Expression Validator Length</title>
    <updated-at type="datetime">2009-07-21T12:32:01-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Often we want to make sure a user does not click more than once on a particular function. Usually with things that write to the database or activate payment, we want to control this. You can use the following with a LinkButton or a standart asp.net Button.&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
protected void Page_Load(object sender, EventArgs e)
{
     LinkButtonSave.Attributes.Add("OnClick", "this.disabled=true; this.onclick=function() { return false;}");
}
&lt;/pre&gt;
&lt;p&gt;Note that this needs to be called from the codebehind, usually page_load works&lt;/p&gt;</content>
    <created-at type="datetime">2009-06-30T16:29:42-07:00</created-at>
    <id type="integer">32</id>
    <title>Disable LinkButton on click</title>
    <updated-at type="datetime">2009-06-30T16:32:27-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">6</category-id>
    <content>&lt;p&gt;In Sitefinity, we sometimes want to be able to know if a custom user control we have built is in edit mode, ie when you are in the designer. This can be useful to not execute javascript or not draw certain things that would mess up the usability / cause errors in the designer. It is quite easy, we are basically checking for the querystring cmspagemode. &lt;/p&gt;

&lt;pre name="code" class="csharp"&gt;
string mode = Request.Querystring.Get("cmspagemode");

if(mode != null)
{
    // running in SF preview mode
    if(mode == "edit")
    {
        // running in edit mode
    }
}
&lt;/pre&gt;</content>
    <created-at type="datetime">2009-06-03T11:05:57-07:00</created-at>
    <id type="integer">31</id>
    <title>Check if user control in edit mode</title>
    <updated-at type="datetime">2009-06-03T11:09:23-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;This is a neat trick to get a tooltip when a user hovers over a row in a gridview. It is very simple and uses standards.&lt;/p&gt;
&lt;p&gt;Simply attach something like this to the GridView's RowDataBound event:&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
protected void GridViewEligibleProducts_RowDataBound(object sender, GridViewRowEventArgs e)
{
   if (e.Row.RowType == DataControlRowType.DataRow)
   {
      // get the row view to be able to access data from the binding object
      DataRowView drv = (DataRowView)e.Row.DataItem;
      // lets me type safe, optional
      ProductsSvc.DSProducts.AgencyEligibleProductsRow thisRow = (ProductsSvc.DSProducts.AgencyEligibleProductsRow)drv.Row;
      // this is the magic to get the tooltip. You could put anything as the 2nd parameter
      e.Row.Attributes.Add("title", (thisRow.IsdescriptionNull() ? "" : thisRow.description));
   }
}
&lt;/pre&gt;</content>
    <created-at type="datetime">2009-04-21T11:21:55-07:00</created-at>
    <id type="integer">30</id>
    <title>GridView Row Tooltip hover</title>
    <updated-at type="datetime">2009-04-21T11:27:31-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;This comes in handy sometimes. Use it to turn a Color object into an HTML compatible Hex string that the browser can understand. &lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
private string ConvertColorToHex(Color color)
		{
			string hexColor = color.R.ToString("X") + color.G.ToString("X") + color.B.ToString("X");
			return hexColor;
		}
&lt;/pre&gt;</content>
    <created-at type="datetime">2009-03-18T18:02:04-07:00</created-at>
    <id type="integer">29</id>
    <title>Convert System.Drawing.Color into Hex String</title>
    <updated-at type="datetime">2009-03-18T18:02:38-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Do you ever have an object lying around that you would like to save off to the database and then be able to retrieve it later as that same object type? Then this might help you. Note that it only works with class objects that are serializable, and these must have a parameterless constructor.&lt;/p&gt;
&lt;p&gt;They come in handy to serialize Generic List objects too.&lt;/p&gt;

&lt;pre name="code" class="csharp"&gt;
		public static string SerializeToString(object obj)
		{
			string output = null;
			if (obj != null)
			{
				XmlSerializer serializer = new XmlSerializer(obj.GetType());

				using (StringWriter writer = new StringWriter())
				{
					serializer.Serialize(writer, obj);

					output = writer.ToString();
				}
			}
			return output;
		}
&lt;/pre&gt;

&lt;p&gt; And then to serialize back into the object:&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
		public static T SerializeFromString&lt;T&gt;(string xml)
		{
			XmlSerializer serializer = new XmlSerializer(typeof(T));

			using (StringReader reader = new StringReader(xml))
			{
				return (T)serializer.Deserialize(reader);
			}
		}
&lt;/pre&gt;</content>
    <created-at type="datetime">2009-03-18T17:51:12-07:00</created-at>
    <id type="integer">28</id>
    <title>Serialize to and from XML</title>
    <updated-at type="datetime">2009-03-18T17:59:16-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">5</category-id>
    <content>&lt;pre name="code" class="javascript"&gt;
function ShowItem(itemId) {
		var item = $get(itemId);
		if (item.style.display == "none" || item.style.display == "") {
			item.style.display = "block";
		}
		else {
			item.style.display = "none";
		}
	}
&lt;/pre&gt;
&lt;p&gt;
If you are using masterpages, you will want to do something like this in your CS codebehind:
&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
HyperLinkLogin.NavigateUrl = String.Format("javascript:ShowItem('{0}');", LoginPanel.ClientID);
&lt;/pre&gt;</content>
    <created-at type="datetime">2009-03-02T12:16:38-08:00</created-at>
    <id type="integer">27</id>
    <title>Show Item with javascript</title>
    <updated-at type="datetime">2009-03-02T12:21:24-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Let's say you have a GridView and you have the RowCommand defined to a function. We often want to get access to the controls in the Row so as to see what values the user selected. Here is an example:&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
protected void GridView1Items_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "ViewList")
    {
        // Here is the trick to get access to the Row.
        GridViewRow row = (GridViewRow)((Control)e.CommandSource).Parent.Parent;
	// Now we can access a dropdown for example and get the selected value.
        DropDownList ddLists = (DropDownList)row.FindControl("DropDownLists");
	int listId = Convert.ToInt32(ddLists.SelectedValue);
	PreviewList1.ListId = listId;
    }
&lt;/pre&gt;
&lt;p&gt;This comes in handy almost any time you want to override the GridView's default behavior for editing / inserting data.&lt;/p&gt;</content>
    <created-at type="datetime">2008-11-11T15:44:17-08:00</created-at>
    <id type="integer">26</id>
    <title>Access Control From GridView RowCommand</title>
    <updated-at type="datetime">2008-11-11T15:55:52-08:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Assume we have a database table with an ID and a Image Datatype column, plus maybe some other info.
We will add a WebForm that will be used to display the image. We can call it something like DisplayImage.aspx and it will be passed a Querystring "id" to know which record from the database table to get. Then, wherever we need to display an image, we just set the ImageUrl property of an asp Image control to "~/DisplayImage.aspx?id=1234"&lt;/p&gt;
&lt;p&gt;First let's build the DisplayImage.aspx file. Go into the codebehind and do something like this:
&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
protected void Page_Load(object sender, EventArgs e)
{
   if (!String.IsNullOrEmpty(Request.QueryString["id"]))
   {
      int logoId = Convert.ToInt32(Request.QueryString["id"]);
      project.LogosSvc webservice = new project.subSvc.LogosSvc();

      sbSvc.DSTemplates.logosDataTable table = webservice.GetLogoById(logoId);

      if (table.Count &gt; 0)
      {
         Response.ContentType = table[0].mime_type;
	 Response.BinaryWrite(table[0].logo);
      }
   }
}
&lt;/pre&gt;
&lt;p&gt;Now in any other file where you want to use the image with that record from DB, then simply do something like this in the cs. (First add asp Image control in .aspx webform and give it ID ImageLogo)
&lt;pre name="code" class="csharp"&gt;
int logoId = 123;
ImageLogo.ImageUrl = String.Format("~/DisplayImage.aspx?id={0}",logoId);
&lt;/pre&gt;</content>
    <created-at type="datetime">2008-10-30T14:24:40-07:00</created-at>
    <id type="integer">25</id>
    <title>Display Image From Database row</title>
    <updated-at type="datetime">2008-10-30T14:33:34-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Placing certain configuration global variables in the web.config can be very useful. It can save you having to re-deploy your application to production, which can in some scenarios be a scary thing. It also gives you a centralized place for keeping track of important constant variables, which you can access from anywhere in your app&lt;/p&gt;
&lt;p&gt;To extract the variable it depends on where in the structure of your site it is located. If you simply have an app with one web.config, it is quite simple and Intellisense helps you our. If you have multiple apps within an app, and the app setting you want is in the website root web.config, use the second method below. &lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
// standard method
string connectString = myproject.Properties.Settings.Default.SettingsConnectionString;

// website root web.config
connectString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
&lt;/pre&gt;

&lt;p&gt;To place the Global setting in your project visually, simply: Right Click on the Properties Folder at the top of your Project and choose Open. Click the "Settings" tab on the left, and you will see the application settings listed.&lt;/p&gt;
&lt;p&gt;To place the settings manually, edit your Web.config and add the following code, editing for your needs.&lt;/p&gt;
&lt;pre name="code" class="xml"&gt;
&lt;applicationSettings&gt;
    &lt;myproject.Properties.Settings&gt;
      &lt;setting name="SettingConnectionString" serializeAs="String"&gt;
        &lt;value&gt;SQL SERVER: blah/blah etc USEMIRROR=true&lt;/value&gt;
      &lt;/setting&gt;
    &lt;/myproject.Properties.Settings&gt;
&lt;/applicationSettings&gt;
&lt;/pre&gt;</content>
    <created-at type="datetime">2008-10-23T16:59:04-07:00</created-at>
    <id type="integer">24</id>
    <title>Global Web.Config Settings</title>
    <updated-at type="datetime">2008-10-23T17:21:45-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Building an XML document object can come in handy often and is a good way to represent data. Here is an example using the XMLTextWriter. This will build a hierarchical xml text representation of some data. At the end we will convert it to an XDocument object, which can be used with LinQ.&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
// fetch some data
Models.ProductGroups group = _dataContext.GetGroupById(id);
// declare objects
StringWriter sw = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(sw);

writer.WriteStartElement("Product");
writer.WriteAttributeString("Id", group.id.ToString());
writer.WriteElementString("Title", group.Name);

writer.WriteStartElement("Products");
// View All Products
writer.WriteStartElement("Product");
writer.WriteAttributeString("Id", "0");
writer.WriteAttributeString("DisplayOrder", "0");

writer.WriteElementString("Title", "View All");
// close product
writer.WriteEndElement(); 
// close console
writer.WriteEndElement(); 
writer.Close();

// now we will have a string with the xml formatted data in it.
string xml = sw.ToString();

// To convert this xml string to an XDocument do the following
XDocument xmlDoc = XDocument.Parse(xml);
&lt;/pre&gt;
&lt;p&gt;
Well, that should give you an idea. You will have to experiment and look at the output xml text to get an idea of how this thing works. Once you convert it to an XDocument object you can do cool things like use LinQ on the object to select specific data.
&lt;/p&gt;</content>
    <created-at type="datetime">2008-10-23T16:25:40-07:00</created-at>
    <id type="integer">23</id>
    <title>XML Text Writer Document building</title>
    <updated-at type="datetime">2008-10-23T16:43:36-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">5</category-id>
    <content>&lt;p&gt;This came in handy when I was using the ModalPopupExtender to pop up a Panel to add a new record. After I had added one item, and hit add again, it would still show the old data. So, I needed a way to clear the text boxes with javascript.&lt;/p&gt;
&lt;p&gt;First add the following javascript function in the head, or referenced js file. If you are using master pages, it can go in there. &lt;/p&gt;
&lt;pre name="code" class="javascript"&gt;
function clearTheInputs(inputType) 
{
     tags = document.getElementsByTagName("input");
     for(i = 0; i &lt; tags.length; i++) {
          if(tags[i].type==inputType) {
                tags[i].value = "";
		}
     }
}
&lt;/pre&gt;

&lt;p&gt;Now, to call this simply do something like this. You could add this in the designer but I'll do it from the codebehind just to demonstrate how it would be done from cs.&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
protected void Page_Load(object sender, EventArgs e)
{
     LinkButtonAddTemplate.Attributes.Add("onclick", "javascript:clearTheInputs('text')");
}
&lt;/pre&gt;</content>
    <created-at type="datetime">2008-10-21T17:29:49-07:00</created-at>
    <id type="integer">22</id>
    <title>Reset Input Text Boxes or other Controls</title>
    <updated-at type="datetime">2008-10-21T17:39:43-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">5</category-id>
    <content>&lt;p&gt;Let's say we have a gridview within an UpdatePanel. The GridView throws some command arguments, ie Edit, Delete, or a Custom LinkButton in a template field with it's CommandArgument set.&lt;/p&gt;
&lt;p&gt;When the GridView's command arguments are fired, only the things in that UpdatePanel will get updated, nothing else. So if we want to intercept that call and for example refresh another update panel we would do the following:&lt;/p&gt;
First set up you update panel like this:
&lt;pre name="code" class="xml"&gt;
&lt;asp:UpdatePanel ID="UpdatePanelList" UpdateMode="Conditional" runat="server" OnLoad="UpdatePanelList_Load"&gt;
&lt;ContentTemplate&gt;
Your Gridview with it's command arguments goes in here...
&lt;/ContentTemplate&gt;
&lt;/asp:UpdatePanel&gt;
&lt;/pre&gt;
&lt;p&gt;Now define the OnLoad function for the updatepanel.&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
protected void UpdatePanelList_Load(object sender, EventArgs e)
{
   if (String.IsNullOrEmpty(Request.Params.Get("__EVENTARGUMENT")) == false)
   {
      // We are gonna pull the commandargument that is coming in as an eventargument from the GV
      int itemId = 0;
      Int32.TryParse(Request.Params.Get("__EVENTARGUMENT"), out itemId);
      // Now we can execute something with that code, or update a different update panel.
      LoadSomething(itemId);
   }
}
&lt;/pre&gt;</content>
    <created-at type="datetime">2008-10-01T17:01:23-07:00</created-at>
    <id type="integer">21</id>
    <title>Intercepting GridView event argument from update panel</title>
    <updated-at type="datetime">2008-10-01T17:09:06-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">5</category-id>
    <content>&lt;p&gt;
When we have forms being submitted that record something to the Database, it is often a good idea to disable the buttons after the first click.&lt;/p&gt;
&lt;p&gt;First add the following code to your header. If you are using master pages, this goes in the masterpage.&lt;/p&gt;
&lt;pre name="code" class="xml"&gt;
&lt;script language="javascript" type="text/javascript"&gt;
		var submitFlag = false;
&lt;/script&gt;
&lt;/pre&gt;
&lt;p&gt;Then, in your code behind you will need to add an onclick attribute to the buttons you want to disable &lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
CheckoutButton.Attributes.Add("onclick", "javascript:if(submitFlag){return false;}else{submitFlag = true; return true;}");
&lt;/pre&gt;

&lt;p&gt;Note that on the onclick attribute you could also do something like $get('buttonClientId').Enabled = false . If you use master pages be sure you are using the right clientId for the button. &lt;/p&gt;</content>
    <created-at type="datetime">2008-09-25T16:57:33-07:00</created-at>
    <id type="integer">20</id>
    <title>Disable Buttons after click</title>
    <updated-at type="datetime">2008-09-25T17:09:25-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;Have you ever had a form with a few fields where users can enter data, and realize that apostrophes give you errors?&lt;/p&gt;
&lt;p&gt;This is where Server.HtmlEncode and Server.HtmlDecode come in very handy. Not only does this fix apoostrophes but other characters that need to be stored as html in the database so that they display correctly on their way out. Also avoid problems when trying to write to the database.&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
string encodedTextForDb = Server.HtmlEncode(TextBoxName.Text);

// When you want to display the text coming out of your db storage correctly:

LabelName.Text = Server.HtmlDecode(dataTable.Name);

&lt;/pre&gt;</content>
    <created-at type="datetime">2008-09-24T11:06:04-07:00</created-at>
    <id type="integer">19</id>
    <title>HtmlEncode: Fix Problems with certain characters</title>
    <updated-at type="datetime">2008-09-24T11:08:57-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;
Lets say you have a comma delimited list of id's in a string object. You want to get these id's into a int[] array. Here is how to do it quick:
&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
string[] idList = someIDs.Split(',');

int[] intIdList = Array.ConvertAll(idList, new Converter&amp;lt;string, int&amp;gt;(StringToInt32));

&lt;/pre&gt;
&lt;p&gt; You will also need to define the follow static function &lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
public static int StringToInt32(string number)
{
     return Convert.ToInt32(number);
}
&lt;/pre&gt;
&lt;p&gt; Wasn't that easy? Note that you can convert other object types too, not simply string to int.
&lt;/p&gt;</content>
    <created-at type="datetime">2008-09-11T15:34:43-07:00</created-at>
    <id type="integer">18</id>
    <title>Convert string array of numbers to int array</title>
    <updated-at type="datetime">2008-09-11T15:57:49-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;So, often we have a radio button list or drop down list that we want to be selected to a certain item when the page loads. You will notice that the only available setter property is the RadioButtonList1.SelectedIndex. It is possible to do set it to the correct SelectedValue using the following code behind (assuming you List has items or is databound):&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
ListItem item = RadioButtonList1.Items.FindByValue("value");
if (item != null)
{
    RadioButtonList1.SelectedIndex = RadioButtonList1.Items.IndexOf(item);
}
&lt;/pre&gt;
&lt;p&gt;
Replace the "value" string for whatever value it is you want selected. The "value" must be a valid value item in the drop down or radio button list.
&lt;/p&gt;</content>
    <created-at type="datetime">2008-09-09T10:32:59-07:00</created-at>
    <id type="integer">17</id>
    <title>Programatically Setting DropDownList / RadioButtonList</title>
    <updated-at type="datetime">2008-09-09T10:37:01-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;So, let's say we have a Dataset for orders and within this dataset we have two tableadapters, one being the master_orders table and the other the child order_details table. The two table adapters are connected by a foreign key relation.&lt;/p&gt;
&lt;p&gt;First thing, when you configure the table adapter query, hit the "advanced" button at the bottom and check all three options. Note that the query must be one that allows for Updating. If not these checkboxes will be greyed out. &lt;/p&gt;
Now we can have some sample code. The DSOrders contains both tables that need to be inserted/updated:
&lt;pre name="code" class="csharp"&gt;
public DSOrders SaveOrder(DSOrders order)
{
// declare the master and child table adapters
    DSOrdersTableAdapters.ordersTableAdapter ordersTa = new DSOrdersTableAdapters.ordersTableAdapter();
				
    DSOrdersTableAdapters.orders_detailTableAdapter detailsTa = new DSOrdersTableAdapters.orders_detailTableAdapter();

// run update for master
    ordersTa.Update(order.orders);
// do a foreach loop and set the parent row
    foreach (DSOrders.orders_detailRow row in order.orders_detail.Rows)
    {
        row.SetParentRow(order.orders[0]);
    }
// run update for child details table
    detailsTa.Update(order.orders_detail);

    return order;
}

&lt;/pre&gt;

&lt;p&gt;By the way, this would be a good example of when to use Transactions. Look for my post on using transactions&lt;/p&gt;</content>
    <created-at type="datetime">2008-08-27T18:21:20-07:00</created-at>
    <id type="integer">16</id>
    <title>Updating Dataset with Foreign key</title>
    <updated-at type="datetime">2008-08-27T18:21:20-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;It took me a while to figure this out but it is quite useful, specially when you want to split on a windows newline, ie. \r\n
&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
strint str = "first line \r\n another line \r\n blank";

string[] array = str.Split(new string[] { "\r\n" }, StringSplitOptions.None);

&lt;/pre&gt;

Now you can iterate through array and have the lines nicely split. By the way, this is faster than using regex for relatively short strings, under 400 chars.</content>
    <created-at type="datetime">2008-08-26T12:09:45-07:00</created-at>
    <id type="integer">15</id>
    <title>Split a string with multiple characters or newline</title>
    <updated-at type="datetime">2008-08-26T12:09:45-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;When needing to store data for use in a different postback we can use either a session or viewstate key. &lt;br /&gt;
The &lt;b&gt;Session&lt;/b&gt; object is kept on the server and can be used in different pages. So if you need an object that will always be available no matter where in your web application the user is, you should use the Session.&lt;br /&gt;
The &lt;b&gt;Viewstate&lt;/b&gt; is kept on the client, and is actually encoded into the html page that is spit out to the client. It is only available in the page that it was defined. You can postback to the same page and have access to the defined viewstate but if the user goes to a different page and comes back, the viewstate will be gone. &lt;/p&gt;
Using a Session:
&lt;pre name="code" class="csharp"&gt;
// setting it
int number = 25;
Session["key1"] = number;
// retrieving
int num2 = (int)Session["key1"];
// note how you must type cast it to get it out correctly

// you can also put in any serializable object, ie a datatable.
DataSetClients.ClientsTable table = WebService.GetClients();
Session["key2"] = table;
// to retrieve simply cast it
table = (DataSetClients.ClientsTable)Session["key2"];

// check if Session is defined and exists
if(Session["key1"] == null)
{
    // not defined
}
&lt;/pre&gt;
&lt;p&gt;You can interchange the above for ViewState["key3"] and get the same result. &lt;/p&gt;</content>
    <created-at type="datetime">2008-08-13T11:35:31-07:00</created-at>
    <id type="integer">14</id>
    <title>Viewstate and Session</title>
    <updated-at type="datetime">2008-08-13T11:36:38-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;I often forget which one of these to use in what scenario:&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
Server.Transfer("~/admin/someurl.aspx");

Request.Redirect("/control/anotherurl.aspx");
&lt;/pre&gt;
&lt;p&gt;In essence, they do the same thing, simply take you to the page you specify as a parameter. But they do this in different ways.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Request.Redirect&lt;/b&gt; actually sends a 304 and loads the url as if you typed it in and hit enter. You should use this when you need to pass querystrings in the redirection url. The url at the top will actually change, so any previous querystrings will not stick. Also, you cannot use the PreviousPage c sharp command to have access to variables in the page doing the redirection.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Server.Transfer&lt;/b&gt; on the other hand does not hit the client. The url in you browser window will not change although you will be in a different page. This means previous querystring will stick. This also means you shouldn't use it to pass querystrings in the redirection url. The cool thing about it is that you can use PreviousPage on the page you transferred to so as to get access to variables in the transferred from page.&lt;br /&gt;
In load balanced scenarios, Server.Transfer will actually keep the object and the client connected to the same sever. If you use Request.Redirect the client could end up requesting from another server. Depending on what it is you are trying to do, keep this in mind. &lt;/p&gt;</content>
    <created-at type="datetime">2008-08-06T14:49:37-07:00</created-at>
    <id type="integer">13</id>
    <title>Request.Redirect vs. Server.Transfer</title>
    <updated-at type="datetime">2008-08-06T14:49:37-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>Enumerators can come in handy anyplace where you need a list of items that could be passed in as parameters. This way you avoid using a string or an integer that could get messed up and cause a run time error. Declared enums provide intellisense in VS so they are quick to code too.

&lt;p&gt;An example would be user types or groups, ie Admin, public, editor, etc. &lt;br /&gt; 
In many cases it is better to have types databound to sql database but for simpler things an enum will do. &lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
public enum Groups
{
   Unknown = 0,
   admin = 1,
   editor = 2,
   everyone = 3
}

int admin = (int)Groups.admin;
// the above would return integer with value 1
Groups group = (Groups)2;
// the above would return enum Group object with "editor" option selected.
&lt;/pre&gt;

Note that I define the integer value of each item and start with Unknown = 0. There is a bug that causes an enum not to travel well through web services. So, if you are declaring an enum in a web service and want to access it on the client, be sure to start with 0. 
&lt;br /&gt;
To bind an enum to a dropdown box or other datasource, this guy has a good article that works: 
http://www.developerfusion.com/code/4713/binding-a-control-to-an-enum/
&lt;br /&gt;
</content>
    <created-at type="datetime">2008-08-01T16:08:24-07:00</created-at>
    <id type="integer">12</id>
    <title>Enum is for Enumeration</title>
    <updated-at type="datetime">2009-09-14T14:41:10-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>Quick how to on using generics and arrays:
&lt;br /&gt;
To declare a new generic list and then do operations with it:
&lt;pre name="code" class="csharp"&gt;
List&lt;int&gt; intsGeneric = new List&lt;int&gt;();
// Add item to list
intsGeneric.Add(234);
// convert to array
int[] intsArray = intsGeneric.ToArray();
&lt;/pre&gt;

&lt;p&gt;Note you can create a generic of any type of object, including your own objects.
&lt;/p&gt;

</content>
    <created-at type="datetime">2008-07-22T15:43:19-07:00</created-at>
    <id type="integer">11</id>
    <title>Generics and Arrays</title>
    <updated-at type="datetime">2008-07-22T15:46:55-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">5</category-id>
    <content>&lt;p&gt;
The asp net AJAX library has some useful things built into it. One thing I found I needed was how to find object components or page dotnet controls.
&lt;/p&gt;
&lt;p&gt;By page objects I mean javascript objects registered like this:&lt;/p&gt;
&lt;pre name="code" class="javascript"&gt;
var app = Sys.Application;
			app.add_load(applicationLoadHandler);

function applicationLoadHandler(sender, args) {
$create(MsdnMag.Timer, 
		            {enabled:true, id:"SULTimer", timeout:60000}, 
		            {tick:OnTick}, null, null);
}
&lt;/pre&gt;

&lt;p&gt; To find them you can do something like in this example:&lt;/p&gt;
&lt;pre name="code" class="javascript"&gt;
if(typeof(this._components["SULTimer"]) !== 'undefined')
{
// then the object SULTimer exists
}
&lt;/pre&gt;</content>
    <created-at type="datetime">2008-07-16T15:50:50-07:00</created-at>
    <id type="integer">10</id>
    <title>Finding page Components</title>
    <updated-at type="datetime">2008-07-16T15:50:50-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">5</category-id>
    <content>The accordion control from the ajax control toolkit can be pretty nice for building Hierarchical structures. The accordion provides expand and collapse to preserve screen real estate and keep the view organized.
&lt;p&gt;
Lets start with the aspx side: Drag in your controls and make em look like this:
&lt;/p&gt;
&lt;pre name="code" class="xml"&gt;
&lt;cc1:Accordion ID="Accordion1" ContentCssClass="accordionContent" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected" SelectedIndex="0"
                     FadeTransitions="true" FramesPerSecond="30" TransitionDuration="300" AutoSize="None" DataSourceID="ODSIssues" runat="server" OnItemDataBound="Accordion1_ItemDataBound"&gt;
                     &lt;HeaderTemplate&gt;
                        &lt;a href="" onclick="return false;"&gt;&amp;lt;%# Eval("Date", "{0:yyyy}") %&gt; &lt;/a&gt;
                     &lt;/HeaderTemplate&gt;
                     &lt;ContentTemplate&gt;
                         &lt;asp:HiddenField ID="HiddenField1" Value='&amp;lt;%# Eval("Date", "{0:yyyy}") %&gt;' runat="server" /&gt;
                         &lt;cc1:Accordion ID="AccordionMonths" ContentCssClass="accordionContent" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected" OnItemDataBound="AccordionMonths_ItemDataBound" SelectedIndex="0"
                          FadeTransitions="true" FramesPerSecond="30" TransitionDuration="300" AutoSize="None" runat="server"&gt;
                            &lt;HeaderTemplate&gt;
                                &lt;a href="" onclick="return false;"&gt;&amp;lt;%# Eval("Date", "{0:MMMM}")%&gt; &lt;/a&gt;
                            &lt;/HeaderTemplate&gt;
                            &lt;ContentTemplate&gt;
                                &lt;asp:HiddenField ID="HiddenFieldMonth" Value='&amp;lt;%# Eval("Date", "{0:d}") %&gt;' runat="server" /&gt;
                                &lt;asp:GridView ID="GridViewDates" runat="server"&gt;
                                &lt;/asp:GridView&gt;
                            &lt;/ContentTemplate&gt;
                         &lt;/cc1:Accordion&gt;
                         
                     &lt;/ContentTemplate&gt;
                    &lt;/cc1:Accordion&gt;
                    &lt;asp:ObjectDataSource ID="ODSIssues" runat="server" SelectMethod="LoadArchiveYears"
                        TypeName="IssuesData"&gt;&lt;/asp:ObjectDataSource&gt;
&lt;/pre&gt;
&lt;p&gt;
Notice a few things: In this example we are using a dates based hierarchy, starting out with the years and coming down to the months and finally to the days in that month.&lt;br /&gt;
The outer Accordion pane, Accordion1, is databound to an object datasource that puts out a table with a column "Date". &lt;br /&gt;
The inner accordion is not databound to anything, it will be databound in the codebehind. This is because we need to pull that value from the hiddenField that will let us know what year/month we need to build the next accordion pane for. &lt;br/&gt;
At the end we just have a GridView that lists the final days in the archive for the selected month.&lt;/p&gt;
&lt;p&gt;
Now for the css that provides the look, alter this to get something different than the default view provided by microsoft.
&lt;/p&gt;
&lt;pre name="code" class="css"&gt;
.accordionHeader
{
    border: 1px solid #2F4F4F;
    color: white;
    background-color: #2E4d7B;
	font-family: Arial, Sans-Serif;
	font-size: 12px;
	font-weight: bold;
    padding: 5px;
    margin-top: 5px;
    cursor: pointer;
}
.accordionHeader a
{
	color: #FFFFFF;
	background: none;
	text-decoration: none;
}
.accordionHeader a:hover
{
	background: none;
	text-decoration: underline;
}

.accordionHeaderSelected
{
    border: 1px solid #2F4F4F;
    color: white;
    background-color: #5078B3;
	font-family: Arial, Sans-Serif;
	font-size: 12px;
	font-weight: bold;
    padding: 5px;
    margin-top: 5px;
    cursor: pointer;
}
.accordionHeaderSelected a
{
	color: #FFFFFF;
	background: none;
	text-decoration: none;
}

.accordionHeaderSelected a:hover
{
	background: none;
	text-decoration: underline;
}

.accordionContent
{
    background-color: #D3DEEF;
    border: 1px dashed #2F4F4F;
    border-top: none;
    padding: 5px;
    padding-top: 10px;
}
&lt;/pre&gt;

&lt;p&gt; Finally lets get to the codebehind, written in c-sharp of course:
&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
protected void Accordion1_ItemDataBound(object sender, AjaxControlToolkit.AccordionItemEventArgs e)
    {
        IssuesData data = new IssuesData();

        if (e.ItemType == AjaxControlToolkit.AccordionItemType.Content)
        {
            AjaxControlToolkit.AccordionContentPanel contentPanel = e.AccordionItem;

            HiddenField yearHf = (HiddenField)contentPanel.FindControl("HiddenField1");

            AjaxControlToolkit.Accordion innerAccordion = (AjaxControlToolkit.Accordion)contentPanel.FindControl("AccordionMonths");
            innerAccordion.DataSource = data.LoadArchiveMonths(yearHf.Value);
            innerAccordion.DataBind();
        }


    }

    protected void AccordionMonths_ItemDataBound(object sender, AjaxControlToolkit.AccordionItemEventArgs e)
    {
        IssuesData data = new IssuesData();

        if (e.ItemType == AjaxControlToolkit.AccordionItemType.Content)
        {
            AjaxControlToolkit.AccordionContentPanel contentPanel = e.AccordionItem;

            HiddenField monthHf = (HiddenField)contentPanel.FindControl("HiddenFieldMonth");

            DateTime monthDate = Convert.ToDateTime(monthHf.Value);

            GridView datalist = (GridView)contentPanel.FindControl("GridViewDates");
            datalist.DataSource = data.LoadArchiveForMonth(monthDate.Month, monthDate.Year);
            datalist.DataBind();
        }
    
    }
&lt;/pre&gt;
&lt;p&gt; Notice that these are the on row / item commands that get run during databinding. Note how we pull the hiddenfield value to then build the inner accordion pane with the right data, and further build the GridView with the right data.
&lt;/p&gt;</content>
    <created-at type="datetime">2008-07-15T11:32:24-07:00</created-at>
    <id type="integer">9</id>
    <title>Hierarchical Ajax Accordion + Databound</title>
    <updated-at type="datetime">2008-08-13T11:41:01-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;To get a DateTime object as a string, or get different parts of it, you can do something like this:&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
DateTime date = DateTime.Now;

string dirName = String.Format("{0:yyyy}{0:MM}{0:dd}", date);
&lt;/pre&gt;
This would output: YYYYMMDD with leading zeroes.

To see a full list of formatting parameters got to: http://msdn.microsoft.com/en-us/library/8kb3ddd4(VS.71).aspx
</content>
    <created-at type="datetime">2008-07-10T18:26:48-07:00</created-at>
    <id type="integer">8</id>
    <title>Date object to string formatting</title>
    <updated-at type="datetime">2008-07-10T18:27:35-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>Notice the formatting, like in String.Format: 
&lt;pre name="code" class="xml"&gt;
&lt;asp:TemplateField HeaderText="Actions"&gt;
&lt;ItemTemplate&gt;
&amp;lt;%# Eval("content_id", "/cms400/custom/AXtraWebContent.aspx?id={0}") %&gt;
&lt;/ItemTemplate&gt;
&lt;/asp:TemplateField&gt;
&lt;/pre&gt;</content>
    <created-at type="datetime">2008-07-01T13:55:03-07:00</created-at>
    <id type="integer">7</id>
    <title>Binding Data in Template Fields GridView</title>
    <updated-at type="datetime">2008-07-15T23:22:54-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">4</category-id>
    <content>&lt;p&gt; Very easy to change a database name in sql server, but it must be done via a sql command&lt;/p&gt;
&lt;pre name="code" class="sql"&gt;
 &#8212;-Create db for test
CREATE DATABASE Test
GO
    &#8212;-Rename the Database Test
ALTER DATABASE Test MODIFY NAME = "New Test"
GO

&lt;/pre&gt;</content>
    <created-at type="datetime">2008-06-27T16:28:38-07:00</created-at>
    <id type="integer">6</id>
    <title>Change Database Name in SQL Server</title>
    <updated-at type="datetime">2008-06-27T16:28:38-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>&lt;p&gt;It is important to use transactions when inserting or doing a lot of database manipulation. Here is a quick example:&lt;p/&gt;
&lt;pre name="code" class="csharp"&gt; 
 using (TransactionScope scope = new TransactionScope())
            {
                SomeDSTableAdapters.cs_recordsTableAdapter ta = new SomeDSTableAdapters.cs_recordsTableAdapter();
                ta.Connection.ConnectionString = _connectionString;
                ta.DeleteAllRecords();

                ta.Update(ds);

                scope.Complete();
            }
&lt;/pre&gt;
&lt;p&gt;
To Enable transactions go to "References" (in your project), right click and hit "Add Reference" and scroll down to System.Transactions and hit Ok. Next add the following code to the very top of your cs file:
&lt;/p&gt;
&lt;pre name="code" class="csharp"&gt;
using System.Transactions;
&lt;/pre&gt;
&lt;br /&gt;</content>
    <created-at type="datetime">2008-06-27T12:26:12-07:00</created-at>
    <id type="integer">5</id>
    <title>Using Transactions</title>
    <updated-at type="datetime">2008-09-04T12:45:26-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">3</category-id>
    <content>So, lets say you are trying to draw a button dynamically using System.Drawing. You pull in the corners from an existing png file but the corner edges are white, so when overlaying they look funny.&lt;br&gt;
Here is what we do:
&lt;pre name="code" class="csharp"&gt;
Bitmap bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);

Bitmap left = new Bitmap(Server.MapPath("~/custom/controls/button/btn_tall_off_left.png"));
left.MakeTransparent(Color.White);
&lt;/pre&gt;

The color you want to make transparent in the png is what you pass into the MakeTransparent() method.</content>
    <created-at type="datetime">2008-06-25T11:45:49-07:00</created-at>
    <id type="integer">4</id>
    <title>How to make bmp Transparent</title>
    <updated-at type="datetime">2008-06-25T11:47:53-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">2</category-id>
    <content>Lets say you want to change the Visual state of a control, for example button1.

In the codebehind you would go:
&lt;pre name="code" class="csharp"&gt;
VisualStateManager.GoToState(button1, "MouseOver", true);
&lt;/pre&gt;
Notes: You can only set the visual state of a control that is of control type, ie a Button has visual states but a Grid or TextBlock does not. I know that is lame...</content>
    <created-at type="datetime">2008-06-19T11:35:32-07:00</created-at>
    <id type="integer">3</id>
    <title>Changing Visual State from Codebehind</title>
    <updated-at type="datetime">2008-06-21T00:36:53-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">2</category-id>
    <content>So, lets say that you created a silverlight button control and you are overriding the default template with your own defined template.

Now, let's say you need to databind, say, the TextBlock text property on an event, but you cannot acces the TextBlock directly because it is within a template.

Solution: Simply set the TextBlock Text property to: 
&lt;pre name="code" class="c-sharp"&gt;
{Binding ObjectPropertyName}
&lt;/pre&gt; and then in the code behind in your event that will bind the data, go: 
&lt;pre name="code" class="c-sharp"&gt;
Button.DataContext = ObjectWithDefinedProperties;
&lt;/pre&gt;
</content>
    <created-at type="datetime">2008-06-18T16:12:49-07:00</created-at>
    <id type="integer">2</id>
    <title>Accessing Controls in a Template to Databind Properties</title>
    <updated-at type="datetime">2008-06-21T00:23:22-07:00</updated-at>
  </entry>
  <entry>
    <category-id type="integer">1</category-id>
    <content>We must override the TableAdapter by using partial classes in a seperate .cs file and thus access the command timeout.
</content>
    <created-at type="datetime">2008-06-18T08:57:39-07:00</created-at>
    <id type="integer">1</id>
    <title>How To Access the Command Timeout in a TableAdapter</title>
    <updated-at type="datetime">2008-06-19T15:42:00-07:00</updated-at>
  </entry>
</entries>
