예제 #1
0
        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;
            }
        }
예제 #2
0
        public static HtmlGenericControl CreateJavaScriptLink(string scriptUrl)
        {
            var script = new HtmlGenericControl("script");

            script.Attributes.Add("type", "text/javascript");
            script.Attributes.Add("src", script.ResolveUrl(scriptUrl));

            return(script);
        }
예제 #3
0
        private static HtmlGenericControl Create_JS_Link(string jsFilePath)
        {
            var _script = new HtmlGenericControl
            {
                TagName = "script"
            };

            _script.Attributes.Add("type", "text/javascript");
            _script.Attributes.Add("src", _script.ResolveUrl(jsFilePath));
            return(_script);
        }