开发者

Appending javascript code piece to the end of the body tag

I am looking for a way to insert javascript code block to end of ASP.NET page.

Page.ClientScript.RegisterClientScriptBlock(typ开发者_Python百科eof(Page), "showVideo", sScript, true);

is appending to body but js codes are always requesting some js files didn't load or some functions are below of the script.

How can i append scripts that i generated dynamically to the bottom of body?

Thanks for your help.


We are using something like

    public static void GenerateJsTag(this TemplateControl page, string jsCode)
    {
        var jsLink = new HtmlGenericControl {TagName = "script", InnerHtml = jsCode };
        jsLink.Attributes.Add("type", "text/javascript");
        page.Controls.Add(jsLink);
    }

hope that will help ;)


Adding Client-Side Script Blocks with RegisterStartupScript() and RegisterClientScriptBlock()

The only difference between these two methods is where each one emits the script block. RegisterClientScriptBlock() emits the script block at the beginning of the Web Form (right after the tag), while RegisterStartupScript() emits the script block at the end of the Web Form (right before the </form> tag).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜