.net后臺代碼調(diào)用前臺JS的兩種方式
1 這種方式只能調(diào)用簡單的JS代碼。不能調(diào)用自定義的函數(shù)。
string jss = "<script language='javascript' type='text/javascript'> alert('hello')</script>";
Response.Write(jss);
2 通用方法。其中的的 mya()是前臺 代碼 中自定義的一個函數(shù)。
(1)
string sl="<script language='javascript' type='text/javascript'> mya('he')</script>";
Page. ClientScript.RegisterStartupScript(ClientScript.GetType(), "mya", sl);
(2)
string sl="<script language='javascript' type='text/javascript'> mya('he')</script>";
Page.RegisterStartupScript( "mya", sl); //Page的RegisterStartupScript方法已過時,改用ClientScript的RegisterStartupScript方法。
Page.ClientScript 屬性
獲取用于管理腳本、注冊腳本和向頁添加腳本的 ClientScriptManager 對象。//調(diào)用該屬性返回一個ClientScriptManager對象。
備注 :
使用 ClientScript 屬性獲取一個可用于管理腳本、注冊腳本和向網(wǎng)頁添加腳本的ClientScriptManager 對象。有關(guān)更多信息,請參見 ClientScriptManager 類。
ClientScriptManager 類是 ASP.NET 2.0 中新增的類,它替代現(xiàn)在已被否決的用于管理腳本的Page 類方法。
ClientScriptManager 類
在 Web 應(yīng)用程序中定義用于管理客戶端腳本的方法。
ClientScriptManager.RegisterStartupScript 方法 //向客戶端動態(tài)添加腳本
向 Page 對象注冊啟動腳本。
相關(guān)文章
The remote procedure call failed and did not execute的解決辦法
打開IIS隨便訪問一個.asp文件,提示The remote procedure call failed and did not execute2009-11-11
在Repeater控件中通過Eval的方式綁定Style樣式代碼
這篇文章主要介紹了如何在Repeater控件中通過Eval的方式綁定Style樣式,需要的朋友可以參考下2014-04-04
.Net獲取URL中文參數(shù)值的亂碼問題解決方法總結(jié)
這篇文章主要介紹了.Net獲取URL中文參數(shù)值的亂碼問題解決方法,總結(jié)分析了針對URL參數(shù)傳遞中出現(xiàn)的亂碼問題與相應(yīng)的解決方法,具有一定參考借鑒價值,需要的朋友可以參考下2016-08-08

