E
Earl Teigrob
I can create a new custom control (and not change it) and add it to the
toolbox and drag it onto the disign screen and it works just fine,
displaying the text [WebCustomControl]. However, when I add the following
datepicker control to the toolbox, it just shows a yellow dot and thats it.
What happened to the text???
Earl
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Text;
namespace CustomControlLibrary
{
[DefaultProperty("Text"),
ToolboxData("<{0}
atePicker runat=server></{0}
atePicker>")]
public class DatePicker : System.Web.UI.WebControls.WebControl
{
[Bindable(true),
Category("Appearance"),
DefaultValue("")]
public string Text
{
get
{
this.EnsureChildControls();
return ((TextBox)Controls[0]).Text;
}
set
{
this.EnsureChildControls();
((TextBox)Controls[0]).Text = value;
}
}
private static string DatePickerJs_Str=DatePickerJs();
protected override void CreateChildControls()
{
Page.RegisterClientScriptBlock("DatePickerJs",DatePickerJs_Str);
TextBox t = new TextBox();
t.Text="TextBox Text";
t.Width=System.Web.UI.WebControls.Unit.Pixel(80);
this.Controls.Add(t);
this.Controls.Add(new LiteralControl(" <a
href=\"javascript:show_calendar('forms[0]." + t.ClientID + "');\"
onmouseover=\"window.status='Date Picker';return true;\"
onmouseout=\"window.status='';return true;\" TABINDEX=\"25\"><img
src=\"http://" + Page.Request.ServerVariables["SERVER_NAME"]+
Page.Request.ApplicationPath + "/CustomResources/show-calendar.gif\"
width=\"24\" height=\"22\" border=\"0\"></a>"));
}
private static string DatePickerJs()
{
StringBuilder s = new StringBuilder(600);
s.Append("<script language=\"JavaScript\">\n");
s.Append("<!-- Original: Kedar R. Bhave ([email protected]) -->\n");
s.Append("<!-- Web Site: http://www.softricks.com -->\n");
s.Append("<!-- This script and many more are available free online
at -->\n");
s.Append("<!-- The JavaScript Source!!
http://javascript.internet.com -->\n");
s.Append("var weekend = [0,6];\n");
s.Append("var weekendColor = \"#e0e0e0\";\n");
toolbox and drag it onto the disign screen and it works just fine,
displaying the text [WebCustomControl]. However, when I add the following
datepicker control to the toolbox, it just shows a yellow dot and thats it.
What happened to the text???
Earl
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Text;
namespace CustomControlLibrary
{
[DefaultProperty("Text"),
ToolboxData("<{0}
public class DatePicker : System.Web.UI.WebControls.WebControl
{
[Bindable(true),
Category("Appearance"),
DefaultValue("")]
public string Text
{
get
{
this.EnsureChildControls();
return ((TextBox)Controls[0]).Text;
}
set
{
this.EnsureChildControls();
((TextBox)Controls[0]).Text = value;
}
}
private static string DatePickerJs_Str=DatePickerJs();
protected override void CreateChildControls()
{
Page.RegisterClientScriptBlock("DatePickerJs",DatePickerJs_Str);
TextBox t = new TextBox();
t.Text="TextBox Text";
t.Width=System.Web.UI.WebControls.Unit.Pixel(80);
this.Controls.Add(t);
this.Controls.Add(new LiteralControl(" <a
href=\"javascript:show_calendar('forms[0]." + t.ClientID + "');\"
onmouseover=\"window.status='Date Picker';return true;\"
onmouseout=\"window.status='';return true;\" TABINDEX=\"25\"><img
src=\"http://" + Page.Request.ServerVariables["SERVER_NAME"]+
Page.Request.ApplicationPath + "/CustomResources/show-calendar.gif\"
width=\"24\" height=\"22\" border=\"0\"></a>"));
}
private static string DatePickerJs()
{
StringBuilder s = new StringBuilder(600);
s.Append("<script language=\"JavaScript\">\n");
s.Append("<!-- Original: Kedar R. Bhave ([email protected]) -->\n");
s.Append("<!-- Web Site: http://www.softricks.com -->\n");
s.Append("<!-- This script and many more are available free online
at -->\n");
s.Append("<!-- The JavaScript Source!!
http://javascript.internet.com -->\n");
s.Append("var weekend = [0,6];\n");
s.Append("var weekendColor = \"#e0e0e0\";\n");