static void

ASP Webforms Controls

Control Types

Maybe it's just me, but the terms are confusing.

Templated Controls

msdn (user controls) - msdn (custom controls)

AutoEventWireup

Events called twice? AutoEventWireup="true". Visual Studio automatically puts in Handles MyBase.Load (VB) or this.Load += new System.EventHandler(this.Page_Load); (C# InitializeComponent). [msdn].

In VS 2005, AutoEventWireup= true by default, but you also get the declarative onclick syntax. ([msdn2])

Events from User Controls

Exposing a gridview paging event (for a generic event with EventArgs, you don't need the delegate as the type is EventHandler; for custom events you might need a special class that extends EventArgs)

public delegate void PagingEventHandler(object sender, GridViewPageEventArgs e);

public event PagingEventHandler OnPaging;

protected void gvAssets_PageChanging(object sender, GridViewPageEventArgs e)

{

    //raise the event

    if (OnPaging != null) OnPaging(this, e);

}

Label vs Literal vs LiteralControl

To output text or html, use these (in order of preference):

Default buttons and focus

Introduced in 2.0, setting the initial focus and default button is easy and really should be done on every page.

SetFocus(txtInput); //or txtInput.Focus();
Form.DefaultButton = btnSubmit.UniqueID; //not the id or clientId