views:

27

answers:

1

Hello,
I really liked the SubSonic 2.2 calendar control. It is a .Net implementation of the old Dynarch calendar found here.

So I did what any developer would do and I swiped all the code for the calendar and put it in it's own library.

Unfortunately the calendar does not play nice with an update panel.
I got help here for getting the calendar working in an update panel however I still have an issue where if the calendar is in an update panel and it is not visible on the first request the script tags pointing to the JavaScript files do not render.

Here is the code that does that.

    protected override void OnPreRender(EventArgs e)
    {
        string csslink = "<link href='" + Page.ClientScript.GetWebResourceUrl(GetType(), IncludeAssemblyPrefix + "skin.theme.css") + "' rel='stylesheet' type='text/css' />";
        Page.Header.Controls.Add(new LiteralControl(csslink));
        Page.ClientScript.RegisterClientScriptInclude("CalendarMain", Page.ClientScript.GetWebResourceUrl(GetType(), IncludeAssemblyPrefix + "calendar.js"));
        Page.ClientScript.RegisterClientScriptInclude("CalendarSetup", Page.ClientScript.GetWebResourceUrl(GetType(), IncludeAssemblyPrefix + "calendar-setup.js"));

        string langPrefix = IncludeAssemblyPrefix + "lang.calendar-";

        if (String.IsNullOrEmpty(Language))
            Language = DEFAULT_LANGUAGE;

        if (Assembly.GetExecutingAssembly().GetManifestResourceStream(langPrefix + Language + ".js") == null)
            Page.ClientScript.RegisterClientScriptInclude("CalendarLanguage", Page.ClientScript.GetWebResourceUrl(GetType(), langPrefix + DEFAULT_LANGUAGE + ".js"));
        else
            Page.ClientScript.RegisterClientScriptInclude("CalendarLanguage", Page.ClientScript.GetWebResourceUrl(GetType(), langPrefix + Language + ".js"));

        base.OnPreRender(e);
    }
    public string IncludeAssemblyPrefix { get { return Assembly.GetExecutingAssembly().GetName().Name + "."; } }

So my question is, how do I get RegisterClientScriptInclude calls to work when the control is not visible?