How can I find the client id of a dynamically created control?
In my ascx, I have the following snippet.
function DoSomething() {
var loneStar= $find("<%= loneStar.ClientID %>");
loneStar.hide();
}
In my code, I have
public partial class SomeControl: System.Web.UI.UserControl
{
protected Label loneStar = new Label { Text = "Raspeberry", ForeColor = System.Drawing.Color.DarkGray};
private void someOtherMethod()
{
somePanel.Controls.Add(loneStar);
}
}
The problem is that the ClientID on the displayed page appears blank.
What am I missing here?
source
share