服務熱線
153 8323 9821
在實際開發(fā)中如新聞系統(tǒng)就需要利用js來調用某分類的新聞等.
非Codebehind版
Showjs.aspx
----------------------------
<%Response.Write ("document.write('output')")%>
Showjs.html
---------------------------
<script language="JavaScript" Src="Showjs.aspx"></script>
這樣就可以正常查看showjs.html輸出"output"
Codebehind版
用Vs.Net新建showjs.aspx然后把除此句以外的html代碼全部刪除
<%@ Page language="c#" Codebehind="showjs.aspx.cs" AutoEventWireup="false" Inherits="Hover.showjs" %>
然后在showjs.aspx.cs里Page_Load()里
Response.Write ("document.write('output')");
這樣就能正常輸出
否則在Showjs.html里調用此Showjs.aspx時會報腳本錯誤了
因為當你查看showjs.aspx運行時的html代碼你就明白了因為它的輸出不光是document.write('output')
還包括aspx的默認文檔的html代碼所以調用不了!