在ASP.Net中利用JS调用Aspx页面的输出
2011-12-03 06:33
399 查看
在实际开发中如新闻系统就需要利用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代码所以调用不了!
非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代码所以调用不了!
相关文章推荐
- 在ASP.Net中利用JS调用Aspx页面的输出
- 在ASP.Net中利用JS调用Aspx页面的输出
- 在ASP.Net中利用JS调用Aspx页面的输出
- Asp.net aspx 页面调用js 中文乱码问题
- asp.net 子页面调用外部 js
- asp.net页面回传与js调用服务端事件、PostBack的原理详解
- asp.net 页面用js调用后台函数
- asp.net页面回传与js调用服务端事件、PostBack的原理详解(转)
- asp.net页面回传与js调用服务端事件、PostBack的原理详解(转)
- ASP.NET后台输出js大全,页面顶部、form表单中前面与后面、和UpdatePanel(ScriptManager、AJAX)输出JS
- asp.net ajax1.0基础回顾(六):调用ASPX页面方法 推荐
- ASP.net输出JS脚步的类(无AJAX框架)(原作者发布地址http://blog.csdn.net/zhoufoxcn/archive/2008/04/21/2312440.aspx)
- Asp.net CS页面调用Javascript进行Alert输出
- ASP.Net 利用反射调用页面方法
- ASP.NET 封装JS文件到DLL中并在页面中调用
- 【问题】Asp.net MVC 的cshtml页面中调用JS方法传递字符串变量参数
- ASP.NET母版页中调用内容页的方法和web用户控件调用.aspx页面里的方法
- asp.net MVC 如何在aspx页面的head标签里输出Key为常量的ViewData呢?
- webform工程中aspx页面为何不能调用appcode文件夹下的类(ASP.NET特殊文件夹的用法)
- asp.net js文件输出的页面文件为什么会是乱码?