-3
我试图在c#
的页面后面添加一个javascript
到asp.net
代码。如何在asp.net和C#的页面后面的代码中添加javascript代码#
我发现这个网站的一些答案,我已经实现了,但我仍然无法从ScriptManager.RegisterClientScriptBlock()
调用函数。
请检查我的代码;
protected void Page_Load(object sender, EventArgs e)
{
string myScriptValue = "function callMe() {alert('You pressed Me!');}";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "myScriptName", myScriptValue, true);
}
请帮我如何获得callMe()
funtion在Page_Load()
。
[添加客户端脚本asp.net页面动态](HTTPS的可能重复://计算器。 com/questions/1731701/add-client-script-to-asp-net-pages-dynamically) – GoldBishop
你应该使用ScriptManager.RegisterStartupScript而不是ScriptManager.RegisterClientScriptBlock – Ravikumar