How To Include Content of One Page To another Page

In this post i will show how to include the content of one page inside another using Regular expression .
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        <asp:Label ID="lblHtml" runat="server"></asp:Label>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text.RegularExpressions;

public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
      lblHtml.Text= ParseHtml();

    private static string ParseHtml()
        StreamReader sr;
        string html;
        sr = File.OpenText(HttpContext.Current.Server.MapPath("Default.aspx"));
        html = sr.ReadToEnd();

            start = new Regex(@"[\s\S]*<body[^<]*>", RegexOptions.IgnoreCase);
        html = start.Replace(html, "");
        Regex end = new Regex(@"</body[\s\S]*", RegexOptions.IgnoreCase);
        html = end.Replace(html, "");
        return html;

No comments:

Post a Comment