管延文

管延文程序空间 QQ:27651302

导航

生成静态页相关

 

HtmlTemplate\Company\CompanyDetailTemplate.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>沈阳正泰康信动物药业 - 长春市人才招聘网</title>
<meta name="keywords"content="长春市猎头/长春市人事代理/长春市人才派遣/长春市劳务派遣" />
<meta name="description" content="长春市猎头/长春市人事代理/长春市人才派遣/长春市劳务派遣" />
<link href="http://www.cnblogs.com/Css/css.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!--页面顶部-->
<iframe src="http://www.cnblogs.com/ControlCompany/Header_Company_Detail.aspx" width="100%" height="172" frameborder="0" align="middle" scrolling="no"></iframe>
<table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td height="2" bgcolor="#0066ff"></td>
    </tr>
</table>
<!--页面主体-->
<table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td height="350" width="200" valign="top"><!--左侧-->
        <table align="center">
         <tr>
          <td height="400" valign="top">
               <!--企业职位名称列表-->
       <iframe id="Iframe4" src="http://www.cnblogs.com/ControlCompany/Company_JobNameList.aspx?Comid=paraComid" scrolling="no" width="100%" frameborder="0" onload="this.height=100"></iframe>
    <script type="text/javascript">
        
function reinitIframe4() {
            
var iframe = document.getElementById("Iframe4");
            
try {
                
var bHeight = iframe.contentWindow.document.body.scrollHeight;
                
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
                
var height = Math.max(bHeight, dHeight);
                iframe.height 
= height;
            } 
catch (ex) { }
        }
        window.setInterval(
"reinitIframe4()"200);
    
</script>
           </td>
         </tr>
        </table>
      </td>
      <td width="10" background="http://www.cnblogs.com/Images/Line1_2.gif"> <!--中部细线分割条-->
      </td>
      <td width="770" style="PADDING-RIGHT:1px;PADDING-LEFT:1px"><!--右侧-->
         <table width="100%" align="center">
             <tr>
                 <td height="350" valign="top">
                   <!--企业基本资料-->
                    <table width="98%" align="center">
                        <tr>
                            <td width="10%" height="50">
                            </td>
                            <td width="80%" align="center" class="font14">companytitlestr</td>
                            <td width="10%" align="center"><iframe src="http://www.cnblogs.com/ControlPublic/ReadClick.aspx?TypeName=Company&Paramid=paraComid" id="Iframe3" width="80" height="25" frameborder="0" align="middle" scrolling="no"></iframe></td>
                        </tr>
                        <tr>
                            <td>
                           公司行业:
                            </td>
                            <td colspan="2">房地产开发·建筑与工程·服务(中介·物业·监理·设计)</td>
                        </tr>
                         <tr>
                            <td>
                           公司性质:
                            </td>
                            <td colspan="2">私营.民营企业</td>
                        </tr>
                         <tr>
                            <td>
                           公司规模:
                            </td>
                            <td colspan="2">50~200人</td>
                        </tr>
                         <tr>
                            <td>
                           公司地点:
                            </td>
                            <td colspan="2">吉林长春</td>
                        </tr>
                         <tr>
                            
                            <td colspan="3"></td>
                        </tr>
                         <tr>
                            <td>
                          公司简介:
                            </td>
                            <td colspan="2"></td>
                        </tr>
                         <tr>
                            <td colspan="3">
                            companyintrostr
                            </td>
                        </tr>
                        
                    </table>
                 </td>
             </tr>
             <tr>
                 <td height="150">
                   <!--联系方式-->
                    <iframe src="http://www.cnblogs.com/ControlCompany/Company_Contact.aspx?Comid=paraComid" id="Iframe2" width="100%" height="100%" frameborder="0" align="middle" scrolling="no"></iframe>
                 </td>
             </tr>
             <tr>
                <td height="200">
                    <!--企业职位详细列表-->
                   <iframe id="frame_content" src="http://www.cnblogs.com/ControlCompany/Company_JobList.aspx?Comid=paraComid" scrolling="no" width="100%" frameborder="0" onload="this.height=100"></iframe>
    <script type="text/javascript">
        
function reinitIframe() {
            
var iframe = document.getElementById("frame_content");
            
try {
                
var bHeight = iframe.contentWindow.document.body.scrollHeight;
                
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
                
var height = Math.max(bHeight, dHeight);
                iframe.height 
= height;
            } 
catch (ex) { }
        }
        window.setInterval(
"reinitIframe()"200);
    
</script>
                </td>
             </tr>
         </table>
      </td>
    </tr>
</table>
<table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td height="2" bgcolor="#0066ff"></td>
    </tr>
</table>
<!--页面底部-->
<iframe src="http://www.cnblogs.com/ControlPublic/Footer.aspx" width="100%" height="120" frameborder="0" align="middle" scrolling="no"></iframe>
</body>
</html>

 

AddNews.aspx.CS

 

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;

namespace WebUI.TestAndTemp
{
    public partial class AddNews : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public static bool WriteFile(string idp,string stitle,string scontent)
        {
            string path = HttpContext.Current.Server.MapPath("~/Html/Company/");
            Encoding code = Encoding.GetEncoding("gb2312");
            // 读取模板文件
            string temp = HttpContext.Current.Server.MapPath("~/HtmlTemplate/Company/CompanyDetailTemplate.html");
            StreamReader sr = null;
            StreamWriter sw = null;
            string str = "";
            try
            {
                sr = new StreamReader(temp, code);
                str = sr.ReadToEnd(); // 读取文件
            }
            catch (Exception exp)
            {
                HttpContext.Current.Response.Write(exp.Message);
                HttpContext.Current.Response.End();
                sr.Close();
            }


            string htmlfilename = DateTime.Now.ToString("yyyyMMddHHmmss") + ".html";
            // 替换内容
            
// 这时,模板文件已经读入到名称为str的变量中了
            str = str.Replace("paraComid", idp);
            str = str.Replace("companytitlestr", stitle);
            str = str.Replace("companyintrostr", scontent);
            // 写文件
            try
            {
                sw = new StreamWriter(path + htmlfilename, false, code);
                sw.Write(str);
                sw.Flush();
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write(ex.Message);
                HttpContext.Current.Response.End();
            }
            finally
            {
                sw.Close();
            }
            return true;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string idd = this.TextBox1.Text.ToString();
            string st = this.TextBox2.Text.ToString();
            string sc = this.TextBox3.Text.ToString();
            bool iftrue = WriteFile(idd,st,sc);
            if (iftrue == true)
            {
                this.Label1.Text = "生成成功!";
            }
            else
            {
                this.Label1.Text = "生成失败!";
            }

        }
    }
}

 

 

posted on 2011-10-09 10:34  tiger8000  阅读(155)  评论(0编辑  收藏  举报