private void BuildChildControl(string scriptUrl, ScriptPositionMode mode) { switch (mode) { case ScriptPositionMode.Header: HtmlGenericControl ctr = new HtmlGenericControl("script"); ctr.Attributes.Add("language", "javascript"); ctr.Attributes.Add("type", "text/javascript"); ctr.Attributes.Add("src", ctr.ResolveUrl(scriptUrl)); this.Controls.Add(ctr); break; case ScriptPositionMode.ScriptManager: ScriptManager sm = ScriptManager.GetCurrent(this.Page); ExceptionHelper.TrueThrow(sm == null, Resources.DeluxeWebResource.E_NoScriptManager); sm.Scripts.Add(new ScriptReference(scriptUrl)); break; case ScriptPositionMode.BodyStart: this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString(), string.Format(_C_SCRIPT_FORMAT, scriptUrl), false); break; case ScriptPositionMode.BodyEnd: this.Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), string.Format(_C_SCRIPT_FORMAT, scriptUrl), false); break; } }
public void Add(string scriptUrl, ScriptPositionMode mode) { if (_UrlContainer.ContainsKey(scriptUrl) == false) { _UrlContainer.Add(scriptUrl, mode); this.BuildChildControl(scriptUrl, mode); } }
public void Add(string scriptUrl, ScriptPositionMode mode) { //string url = cssUrl.Trim().ToLower(); if (!_UrlContainer.ContainsKey(scriptUrl)) { _UrlContainer.Add(scriptUrl, mode); this.BuildChildControl(scriptUrl, mode); } }