I am looking for a way to insert javascript code block to end of ASP.NET page.
Page.ClientScript.RegisterClientScriptBlock(typeof(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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With