我的a.htm是这样的:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name=ProgId content=VisualStudio.HTML>
<meta name=Originator content="Microsoft Visual Studio .NET 7.1">
<script>
var http_request=false;
function send_request()
{
if(window.XMLHttpRequest)
{
http_request=new XMLHttpRequest();}
else if(window.ActiveXObject)
{
try{
http_request=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
try{
http_request=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{}
}
}
if(!http_request)
{
window.alert('不能创建XMLHttpRequest对象实例.');
return false;
}
http_request.open("GET","WebForm1.aspx",true);
http_request.send(null);
http_request.onreadystatechange=processRequest;}function processRequest(){
if(http_request.readyState==4){
if(http_request.status==200){
document.getElementById("dygdata").innerText=http_request.responseText;
}
else{
document.getElementById("dygdata").innerHTML="您所请求的页面有异常.";
}
}
}
</script>
</head>
<body>
<form id="form1">
<p>不刷新页面获取数据.</p>
<p><span id="dygdata"></span><input type=button value=获取数据 onclick="send_request()"></p>
</form>
</body>
</html>WebForm1.aspx.cs是这样的:using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;namespace test21
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Response.Write("Hello World!");
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{    
this.Load += new System.EventHandler(this.Page_Load); }
#endregion }
}
为什么我运行是接收的不是 Hello World!字符串,而是:
Hello World!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <title>WebForm1</title>
  <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
  <meta name="CODE_LANGUAGE" Content="C#">
  <meta name="vs_defaultClientScript" content="JavaScript">
  <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
 </HEAD>
 <body MS_POSITIONING="GridLayout">
  <form name="Form1" method="post" action="WebForm1.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE" value="dDwtMTI3OTMzNDM4NDs7Pn0et4Ucdcsq7uXAi5wJk3dzIMFI" />   <FONT face="宋体"></FONT>
  </form>
 </body>
</HTML>
请问怎样只获取 Hello World! 呀?

解决方案 »

  1.   

    将WebForm1.aspx页的html代码都删掉,在后台直接response.write"Hello world!".
      

  2.   

    直接抛出文本内容或者是xml文件,将处理文件交个前台处理。
    或者是用xmlhttpquery获取内容以后在用正则过滤不需要内容。另,本人现申请web版ajax斑竹,兄弟们多支持~~
      

  3.   

    是,但是剔除掉所有的html标签
      

  4.   

    如果返回内容需要包容其他内容,就要组xml串,然后再解析。
      

  5.   

    网上下个ajax.net,自己写xmlhttp太麻烦
      

  6.   

    MSDN上有AJAX类库下载
    自己判断不要写死了