-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