protected void ResolveControlIDs(Animation animation)
{
if(animation == null) {
return;
}
// See if the animation had a target
string id;
if(animation.Properties.TryGetValue("AnimationTarget", out id) && !String.IsNullOrEmpty(id)) {
// Try to find a control with the target's id by walking up the NamingContainer tree
Control control = null;
var container = NamingContainer;
while((container != null) && ((control = container.FindControl(id)) == null)) {
container = container.Parent;
}
// If we found a control
if(control != null) {
// Map the server ID to the client ID
animation.Properties["AnimationTarget"] = control.ClientID;
}
}
// Resolve any server control IDs in the animation's children
foreach(var child in animation.Children)
ResolveControlIDs(child);
}