Noticed this annoying quirk today while working on a custom WebForms control. Calling EnsureID will not populate the ClientID property if the control's effective ClientIDMode is set to Static. No idea why! EnsureID will still populate the ID properties, but if you need the ClientID for client-side javascript, you'll need to find other ways around. I opted to go this route:
public override string ClientID
{
get
{
EnsureID();
if (!string.IsNullOrWhiteSpace(ClientID))
{
return ClientID;
}
if (!string.IsNullOrWhiteSpace(ID))
{
return ID;
}
throw new InvalidOperationException("Where's the ClientID for this DateTimePicker?");
}
}