asp.net调用JavaScript自定义方法

方法一:

Page.RegisterStartupScript("function","<script>你要调用的javascript函数名称;</script>");

但此方法在IE6中会崩溃。。。无法在IE6中使用 在IE8中可以用

方法二:

public void Meg(string ag)
{
       LiteralControl li = new LiteralControl();
       li.Text = "<script>javascript自定义函数名称('" + ag + "')</script>";
       Controls.Add(li);

}

此方法适应IE6和IE8

LiteralControl

表示 HTML 元素、文本和 ASP.NET 页中不需要在服务器上处理的任何其他字符串

具体可看:http://msdn.microsoft.com/zh-cn/library/system.web.ui.literalcontrol.aspx

controls :

具体可看:http://msdn.microsoft.com/zh-cn/library/ms164640(VS.80).aspx

原文地址:https://www.cnblogs.com/hun_dan/p/1619050.html