C# ASP.NET Code-Behind 呼叫JS

假設前端有一個 JS


前端

<script>

function test(input){

    alert(input);

}

</script>



後端

ScriptManager.RegisterClientScriptBlock(this, GetType(), "Button popup", "xalert('Welcome to Taiwan!');", true);

如果檢視原始碼,會發現 RegisterClientScriptBlock 那段會轉成

<script type="text/javascript">
//<![CDATA[
xalert('Welcome to Taiwan!');//]]>
</script>


這是2017年的程式碼了,我這邊目前沒有建ASP.NET的環境,只有ASP.Net MVC 跟 ASP.NET Core



參考:
https://blog.xuite.net/tolarku/blog/533226152

留言

這個網誌中的熱門文章

無法載入檔案或組件 'System.IO.Compression' 或其相依性的其中之一。

MongoDB 入門

javascript 更改屬性及創建標籤