Missing ID property for a custom control

Discussion in 'ASP .Net Building Controls' started by Raul S, Jun 27, 2004.

  1. Raul S

    Raul S Guest

    Hello,
    When i'm using a custom control in my project, i can see that the custom control is missing it's ID in the HTML file. I can see the object name, but not it's ID.
    any idea why ?

    Here is the custom control code:

    public class myTime : Control, INamingContainer
    {
    public string Value
    {
    get
    {
    this.EnsureChildControls();
    return ((TextBox)Controls[0]).Text;
    }
    set
    {
    EnsureChildControls();
    ((TextBox)Controls[0]).Text = value.ToString();
    }
    }
    ......
    other properties
    .....

    protected override void CreateChildControls()
    {
    TextBox box = new TextBox();
    box.Columns=1;
    box.MaxLength=5;
    if(System.DateTime.Now.Hour<10)
    box.Text="0"+System.DateTime.Now.Hour+":";
    else
    box.Text=System.DateTime.Now.Hour+":";
    box.Text=box.Text+System.DateTime.Now.Minute;
    box.Attributes.Add("onkeyup","checkTimeObj(this)");
    box.Attributes.Add("onfocusout","checkTimeLength(this)");
    Controls.Add(box);
    System.IO.StringWriter sw=new System.IO.StringWriter();
    System.Text.StringBuilder sb=new System.Text.StringBuilder();
    sb.Append("<script language='javascript'>"+sw.NewLine);
    ......
    javascript code here
    ......
    sb.Append("</script>"+sw.NewLine);
    Page.RegisterClientScriptBlock("myTimeControlJavaScriptKey"+ClientID,sb.ToString());
    }


    Thanks
    Raul S, Jun 27, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TS
    Replies:
    5
    Views:
    404
    Steven Cheng[MSFT]
    Jul 6, 2007
  2. Matt Sokol
    Replies:
    2
    Views:
    379
    Theo Tillotson
    Aug 7, 2003
  3. Rob Joosen

    Keep custom property-value in custom rendered control

    Rob Joosen, May 12, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    142
    Rob Joosen
    May 12, 2004
  4. Zarko Gajic

    Custom Attributes (AttributeTargets.Property) and Property Type

    Zarko Gajic, Apr 7, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    434
    Zarko Gajic
    Apr 7, 2005
  5. anon
    Replies:
    0
    Views:
    210
Loading...

Share This Page