The html element 'input' does not have a load event. 'body', 'img' and 'window' do. There may be others.
I suggest you add a css class to the custom inputs (textboxes) then use something like jQuery to handle the load event of the page to perform your function on all the textboxes with that css class.
The following example assumes you have jQuery and jQueryUI loaded in your page.
public class MyTextBox: TextBox
{
public string DatePickerOptions { get; set; }
public string DateFormatString { get; set; }
public string EmptyDateText { get; set; }
public DateTime? Date
{
get
{
DateTime? date = null;
if ( string.IsNullOrEmpty(Text) )
return date;
DateTime outDateTime;
if (DateTime.TryParse(Text, out outDateTime))
date = outDateTime;
return date;
}
set
{
DateTime? date = value;
if ( date == null || ((DateTime)date).Year < 2 )
Text = EmptyDateText;
else
Text = ((DateTime) date).ToString(DateFormatString);
}
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Text = EmptyDateText;
}
public override void RenderEndTag(System.Web.UI.HtmlTextWriter writer)
{
StringBuilder javaScriptBuilder = new StringBuilder();
javaScriptBuilder.Append("$(function() { $(\"#");
javaScriptBuilder.Append(ClientID);
javaScriptBuilder.Append("\").datepicker(");
javaScriptBuilder.Append(DatePickerOptions);
javaScriptBuilder.Append("); });");
base.RenderEndTag(writer);
writer.WriteLine();
writer.Write("<script type=\"text/javascript\">");
writer.WriteLine();
writer.Indent++;
writer.Write(javaScriptBuilder.ToString());
writer.WriteLine();
writer.Indent--;
writer.Write("</script>");
writer.WriteLine();
writer.Close();
}
}