js调用其他页面输出内容

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

posted @   甜菜波波  阅读(587)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示