I have a Web Custom Control that builds javascript to write to the page.
The DatePickerJs() function builds over 500 lines of javacript code. Even
thought my Custom Web Control does not write it to the client, it
regenerates the string very time this control appears on a page.
Is there a way to create this string ONCE and then just use if every time
after that?
CODE
protected override void CreateChildControls()
{
Page.RegisterClientScriptBlock("DatePickerJs",Date PickerJs());
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 string DatePickerJs()
{
StringBuilder s = new StringBuilder(600);
s.Append("<script language=\"JavaScript\">\n");
s.Append("<!-- Original: Kedar R. Bhave (so*******@hotmail.com) -->\n");
.....