在ASP.Net中利用JS调用Aspx页面的输出

出处:http://www.cnblogs.com/torome/articles/363433.html

在实际开发中如新闻系统就需要利用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代码所以调用不了!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值