------动态加载页面不使用iframe ,Javascript ,include [<!--#include file="文件名地址"-->]-------------
<ul style="list-style-type:none;margin:0;padding:0;">
<li style=" text-decoration:underline"><a href="MIni.aspx?id=1">sfsfsfd</a></li>
<li class="list1"><a href="MIni.aspx?id=2">sfsfsfd</a></li>
<li class="list2"><a href="MIni.aspx?id=3">sfsfsfd</a></li>
<li><a href="MIni.aspx?id=4">sfsfsfd</a></li>
<li><a href="MIni.aspx?id=5">sfsfsfd</a></li>
</ul>
---------------------------------------------------------------------------------------------
public partial class MIni : System.Web.UI.Page
{
protected vo id Page_Load(object sender, EventArgs e)
{
string strId = RequestUtility.GetNonNullQueryString("id");
string strPath = Server.MapPath(string.Format("Uploads/list{0}.htm", strId));
// this.test.InnerHtml = GetPageSource(strPath);
this.test.InnerHtml = GetPageHhml(strPath);
}
/// <summary>
/// 本地
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static string GetPageHhml(string path)
{
string result = null;
if (File.Exists(path))
{
//FileStream fs = new FileStream(path, FileMode.Open);
//StreamReader sr = new StreamReader(path, System.Text.Encoding.Default);
//result = sr.ReadToEnd();
//sr.Close();
//fs.Close();
using (StreamReader sr = new StreamReader(path, System.Text.Encoding.Default))
{
result = sr.ReadToEnd();
}
}
return result;
}
public static string GetPageSource(string strPath)
{
string result = null;
if (File.Exists(strPath))
{
Uri uri = new Uri(strPath);//Uri uri = new Uri("www.baidu.com");
WebClient wb = new WebClient();
wb.Credentials = CredentialCache.DefaultCredentials;
byte[] pagedata = wb.DownloadData(@uri);
result = System.Text.Encoding.UTF8.GetString(pagedata);
}
return result;
}
}
--------------------------------------修改后---MIni.aspx.cs---------------------------------------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using Lodge.ToolKit.Common;
using System.Text;
using System.Text.RegularExpressions;
public partial class MIni : System.Web.UI.Page
{
protected string strJobContent = "";
static Regex reg = new Regex(@"<p class=['""]career_title['""]>(?<title>.*?)</p>", RegexOptions.IgnoreCase);
protected void Page_Load(object sender, EventArgs e)
{
string strId = RequestUtility.GetNonNullQueryString("id");
if (strId != null)
{
string strPath = Server.MapPath(string.Format("Uploads/list{0}.htm", strId));
//MainContent(strId);
GetPageHhml(strPath);
}
}
/// <summary>
/// 本地
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
private void GetPageHhml(string path)
{
if (File.Exists(path))
{
using (StreamReader sr = new StreamReader(path, System.Text.Encoding.Default))
{
strJobContent = sr.ReadToEnd();
Match match = reg.Match(strJobContent);
if (match != "")
{
string strTitle = match.Groups["title"].Value;
Page.Title = strTitle + " " + Page.Title;
}
}
}
}
}
-------------Uploads/list1.htm----------
<div class="list1" style="width:500px;height:500px;background-color:Green;margin-top:5px;">
<p class="career_title">简历搜索</p>
无标题页无标题页无标题页fddffdfdfd
</div>
-------------MIni.aspx----------
<ul style="list-style-type:none;margin:0;padding:0;">
<li style=" text-decoration:underline"><a href="MIni.aspx?id=1">简历搜索</a></li>
<li class="list1"><a href="MIni.aspx?id=2">sfsfsfd</a></li>
<li class="list2"><a href="MIni.aspx?id=3">sfsfsfd</a></li>
<li><a href="MIni.aspx?id=4">sfsfsfd</a></li>
<li><a href="MIni.aspx?id=5">sfsfsfd</a></li>
</ul>
<div>
<%=strJobContent %>
</div>
---------------------------------------------------------项目-----------------------------------------------------------------
<div id="main_left">
<ul>
<li><a href="/Jobs/jobDetail.aspx?name=job1">网页设计师</a></li>
<li><a href="/Jobs/jobDetail.aspx?name=job2">C++程序员(客户端程序员)</a></li>
<li><a href="/Jobs/jobDetail.aspx?name=job3">游戏策划</a></li>
<li><a href="/Jobs/jobDetail.aspx?name=job4">3D美术设计师</a></li>
<li><a href="/Jobs/jobDetail.aspx?name=job5">C++程序员(服务端程序员)</a></li>
<li><a href="/Jobs/jobDetail.aspx?name=job6">游戏客服</a></li>
</ul>
</div>
-----------------------------------------------
public partial class Jobs_jobDetail : System.Web.UI.Page
{
protected string strJobContent = "";
static Regex regJobTitle = new Regex(@"<p class=['""]career_title['""]>(?<title>.*?)</p>", RegexOptions.IgnoreCase);
const string JOB_FILE_PATH = @"~/jobs/job/{0}.html";
protected void Page_Load(object sender, EventArgs e)
{
string strName = RequestUtility.GetNonNullQueryString("name");
if (strName == "" || File.Exists(Server.MapPath(string.Format(JOB_FILE_PATH, strName))) == false)
strName = "job1";
using (StreamReader sr = new StreamReader(Server.MapPath(string.Format(JOB_FILE_PATH, strName)), Encoding.Default))
{
strJobContent = sr.ReadToEnd();
Match match = regJobTitle.Match(strJobContent);
if (match != null)
{
string strTitle = match.Groups["title"].Value;
Page.Title = strTitle + " " + Page.Title;
}
}
}
}