What’s the difference between Control.Select() and Control.Focus()?

Focus() is the low level function that actually sets the focus. Select() is a higer-level method. It first looks iteratively upward in the control’s parent hierarchy until it finds a container control. Then it sets that container’s ActiveControl property (to the called control). The logic in those methods is not straightforward however, and there is … Read more

Unexpected list behavior in Python

The following: list_reversed = list makes the two variables refer to the same list. When you change one, they both change. To make a copy, use list_reversed = list[:] Better still, use the builtin function instead of writing your own: list_reversed = reversed(list) P.S. I’d recommend against using list as a variable name, since it … Read more

ListItems attributes in a DropDownList are lost on postback?

I had the same problem and wanted to contribute this resource where the author created an inherited ListItem Consumer to persist attributes to ViewState. Hopefully it will save someone the time I wasted until I stumbled on it. protected override object SaveViewState() { // create object array for Item count + 1 object[] allStates = … Read more