翱翔.Net

释放.Net的力量
posts - 75, comments - 1131, trackbacks - 5, articles - 18
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

公告

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

Posted on 2004-04-30 22:01 Hover 阅读(2792) 评论(4) 编辑 收藏

在实际开发中如新闻系统就需要利用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代码所以调用不了!
感谢 思归 指点,不愧是真正的Most Valuable Professional .那份热心就够学习的了。希望我没烦死他。呵!这问题简单我才弄明白。哎