Showing posts from September, 2010

Create UserControl with inline content

Let's say you want to create a user control that contains some literal text:
<uc1:InlineContent> This is some standard text message </uc1:InlineContent>Here is the simplest UserControl that matches this description:
using System.Web.UI; [ParseChildren(ChildrenAsProperties = true, DefaultProperty = "Content")] public partial class InlineContent : System.Web.UI.UserControl { [PersistenceMode( PersistenceMode.EncodedInnerDefaultProperty)] publicstring Content { get; set; } }

Adding a delay before processing Textbox events

Typical scenario: You provide the user with a TextBox he can use to type a filter over a big chunk of data that takes a lot of time to process. Most of the time, you would handle the TextChanged event of the TextBox and issue a filter operation over the data source using the character(s) available in the TextBox. Typical problem: The user complains because he has to wait between the key strokes even if he already knows a filter that would allow the search to take place in a matter of a few seconds. Solution: Introduce a delay between the last key stroke and the processing using a timer. Walkthough: Create a new Winforms project with a Form. Add a TextBox (named textBox), a ListBox (named listBox). To mimic a very slow data source, we will create a dummy class: