Getting the Friendly Control ID
Here is a simple utility method that will take a string argument such as
"ctl00$ContentPlaceHolder1$DropDownList1" and return "DropDownList1"
public static string GetFriendlyControlId(string renderedControlId) { // PageIdSeparator is a property returning Page.IdSeparator int indexOfSeparator = renderedControlId.LastIndexOf(PageIdSeparator); if (indexOfSeparator >= 0) { renderedControlId = renderedControlId.Substring(indexOfSeparator + 1); } return renderedControlId; }