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 [WebCustomContro l]. 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.W ebControls;
using System.Componen tModel;
using System.Text;
namespace CustomControlLi brary
{
[DefaultProperty ("Text"),
ToolboxData("<{ 0}:DatePicker runat=server></{0}:DatePicker> ")]
public class DatePicker : System.Web.UI.W ebControls.WebC ontrol
{
[Bindable(true),
Category("Appea rance"),
DefaultValue("" )]
public string Text
{
get
{
this.EnsureChil dControls();
return ((TextBox)Contr ols[0]).Text;
}
set
{
this.EnsureChil dControls();
((TextBox)Contr ols[0]).Text = value;
}
}
private static string DatePickerJs_St r=DatePickerJs( );
protected override void CreateChildCont rols()
{
Page.RegisterCl ientScriptBlock ("DatePickerJs" ,DatePickerJs_S tr);
TextBox t = new TextBox();
t.Text="TextBox Text";
t.Width=System. Web.UI.WebContr ols.Unit.Pixel( 80);
this.Controls.A dd(t);
this.Controls.A dd(new LiteralControl( " <a
href=\"javascri pt:show_calenda r('forms[0]." + t.ClientID + "');\"
onmouseover=\"w indow.status='D ate Picker';return true;\"
onmouseout=\"wi ndow.status=''; return true;\" TABINDEX=\"25\" ><img
src=\"http://" + Page.Request.Se rverVariables["SERVER_NAM E"]+
Page.Request.Ap plicationPath + "/CustomResources/show-calendar.gif\"
width=\"24\" height=\"22\" border=\"0\"></a>"));
}
private static string DatePickerJs()
{
StringBuilder s = new StringBuilder(6 00);
s.Append("<scri pt language=\"Java Script\">\n");
s.Append("<!-- Original: Kedar R. Bhave (so*******@hotm ail.com) -->\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" );