R
Raul S
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
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