/// <summary> /// Explicitly forces the client script to be rendered into the page. /// This code is called automatically by the configured event handler that /// is hooked to Page_PreRenderComplete /// </summary> private void RenderClientScript() { ClientScriptProxy scriptProxy = ClientScriptProxy.Current; string script = GetClientScript(false); // TODO: This has to be fixed for ww.jquery.js if (UpdateMode != AllowUpdateTypes.None) { ScriptLoader.LoadjQuery(Page); ScriptLoader.LoadwwjQuery(Page); scriptProxy.RegisterClientScriptBlock(Page, typeof(ControlResources), "submitServerVars", STR_SUBMITSCRIPT, true); scriptProxy.RegisterHiddenField(Page, "__" + ClientObjectName, ""); script += string.Format(@"$(document.forms['{1}']).submit(function() {{ __submitServerVars({0},'__{0}'); }});", ClientObjectName, Page.Form.ClientID, SubmitCounter++); } scriptProxy.RegisterClientScriptBlock(Page, typeof(ControlResources), "ClientObject_" + ClientObjectName, script, true); }
protected override void OnInit(EventArgs e) { base.OnInit(e); ClientScriptProxy = ClientScriptProxy.Current; }
/// <summary> /// This method just builds the various JavaScript blocks as strings /// and assigns them to the ClientScript object. /// </summary> /// <param name="e"></param> protected override void OnPreRender(EventArgs e) { if (!IsCallback) { ClientScriptProxy = ClientScriptProxy.Current; // If we're not in a callback provide script to client if (!string.IsNullOrEmpty(jQueryScriptLocation)) ScriptLoader.LoadjQuery(this.Page); //ClientScriptProxy.LoadControlScript(this, jQueryScriptLocation, ControlResources.JQUERY_SCRIPT_RESOURCE, ScriptRenderModes.HeaderTop); ClientScriptProxy.LoadControlScript(this, ScriptLocation, ControlResources.WWJQUERY_SCRIPT_RESOURCE, ScriptRenderModes.Header); // Generate the class wrapper and class loader function GenerateControlSpecificJavaScript(); } else { if (PageProcessingMode == CallbackProcessingModes.PagePreRender) HandleCallback(); } }
/// <summary> /// Handle writing out scripts to header or 'ASP.NET script body' /// </summary> /// <param name="e"></param> protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); // Use ClientScript Proxy for all script injection except inline scriptProxy = ClientScriptProxy.Current; // Now process all but inline scripts - // inline scripts must be rendered in Render() foreach (ScriptItem script in InternalScripts) { RegisterScriptItem(script); } }
/// <summary> /// Read the HtmlGeneric Script controls and parse them into /// Internal scripts at page load time /// </summary> /// <param name="e"></param> protected override void OnInit(EventArgs e) { // Save a Per Request instance in Page.Items so we can retrieve it // generically from code with wwScriptContainer.Current if (!Page.Items.Contains(STR_CONTEXTID)) Page.Items[STR_CONTEXTID] = this; else { // ScriptContainer already exists elsewhere on the page - combine scripts ScriptContainer container = Page.Items[STR_CONTEXTID] as ScriptContainer; foreach (HtmlGenericControl scriptItem in container.Scripts) { this.Scripts.Add(scriptItem); } } base.OnInit(e); scriptProxy = ClientScriptProxy.Current; // Pick up HtmlGeneric controls parse into Script objects // and add to Internal scripts for final processing foreach (HtmlGenericControl ctl in Scripts) { // Take generic control and parse into Script object ScriptItem script = ParseScriptProperties(ctl); if (script == null) continue; // Insert into the list at the head of the list before 'manually' // added script entries //AddScript(script); // Register these items immediately at startup // script refs defined in doc take precendence over code added ones RegisterScriptItem(script); } }
/// <summary> /// Code that embeds related resources (.js and css) /// </summary> /// <param name="scriptProxy"></param> protected void RegisterResources(ClientScriptProxy scriptProxy) { // Use ScriptProxy to load jQuery and ww.Jquery ScriptLoader.LoadjQuery(this); ScriptLoader.LoadjQueryUi(this, null); // if a theme is provided embed a link to the stylesheet if (!string.IsNullOrEmpty(Theme)) { string cssPath = this.CssBasePath.Replace("/base/", "/" + Theme + "/"); scriptProxy.RegisterCssLink(Page, typeof(ControlResources), cssPath, cssPath); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (!DesignMode) { ScriptProxy = ClientScriptProxy.Current; // Use ScriptProxy to load jQuery and ww.Jquery if (!string.IsNullOrEmpty(jQueryScriptLocation)) ScriptLoader.LoadjQuery(this); ScriptProxy.LoadControlScript(this, ScriptLocation, ControlResources.WWJQUERY_SCRIPT_RESOURCE, ScriptRenderModes.Header); } }
protected override void OnPreRender(EventArgs e) { ClientScriptProxy = ClientScriptProxy.Current; if (Visible && !string.IsNullOrEmpty(Text) && DisplayTimeout > 0) { // Embed the client script library as Web Resource Link ScriptLoader.LoadjQuery(this); string Script = @"setTimeout(function() { $('#" + ClientID + @"').fadeOut('slow') }," + DisplayTimeout.ToString() + ");"; //@"window.setTimeout(""document.getElementById('" + ClientID + @"').style.display='none';""," + DisplayTimeout.ToString() + @");"; ClientScriptProxy.RegisterStartupScript(this, typeof(ErrorDisplay), "DisplayTimeout", Script, true); } base.OnPreRender(e); }
/// <summary> /// Code that embeds related resources (.js and css) /// </summary> /// <param name="scriptProxy"></param> protected void RegisterResources(ClientScriptProxy scriptProxy) { scriptProxy.LoadControlScript(this, jQueryJs, ControlResources.JQUERY_SCRIPT_RESOURCE, ScriptRenderModes.HeaderTop); scriptProxy.RegisterClientScriptInclude(Page, typeof(ControlResources), CalendarJs, ScriptRenderModes.Header); string cssPath = CalendarCss; if (!string.IsNullOrEmpty(Theme)) cssPath = cssPath.Replace("/base/", "/" + Theme + "/"); scriptProxy.RegisterCssLink(Page, typeof(ControlResources), cssPath, cssPath); }