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
留言
張貼留言