Custom Control not displaying text in Designer

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}:DatePicker runat=server></{0}:DatePicker>")]

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("&nbsp<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");
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top