asp.net静态页面引用动态页

 

静态页调用

<script type="text/javascript" src="../ArticleList.aspx?topnum=8&isImage=1&length=13&template=5&ArticleTypeId={D7396CE1-981E-4ED3-98B4-B02EF9D6E54F}"></script>

<%@ Page Language="C#" AutoEventWireup="true"  %>
<%@ Import Namespace="T_axzf.BLL" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Data" %>

    <script runat="server">
        /*调用参数说明:
     ArticleTypeId:文章类别ID
     ISPopu:是否为推荐,1为推荐,0为全部显示
     isImage:1为查找带图片的新闻,0为全部文章
     topnum:要获取的条数M
     length:文章标题长度
     descriptlength:文章简介长度
     template:模板ID
      * /
        /*  模板代码开始 在此调整样式 请注意备份.
 {0}代表文章ID,
 {1}代表文章未截字的完整标题,
 {2}代表文章标题,
 {3}代表文章简介未截字的完整简介 ,
 {4}代表文章简介 ,
 {5}代表图片缩略图路径(从根路径开始输出)
    {6}代表文章类型ID
    {7}标题样式
         * {8}文章发布时间
*/
        public string[] Templates = {
 /*模板0 井冈山要闻首页调用*/   "<tr><td class='TextCsstype' style='PADDING-LEFT: 5px' valign='center' align='left' height='26'><img height='10'  src='images/imageInc.jpg' width='10'  align='absmiddle' border='0' /> <a title='{1}' href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td><td width='80' >[{8}]</td></tr>",
 /*模板1 政府文件首页调用*/   "<tr><td class='TextCsstype' style='PADDING-LEFT: 5px' valign='center' align='left' height='26'><img height='10'  src='images/imageInc.jpg' width='10'  align='absmiddle' border='0' /> <a title='{1}' href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td><td width='80' >[{8}]</td></tr>",
    /*模板2 工作动态首页调用*/   "<li  align='left' style=' list-style-type:none;line-height:180%;height:20px;padding-top:3px;padding-left:5px' > · <a title='{1}'  href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </li>",
    /*模板3 魅力井冈山图片首页调用*/   "<td width='25%'><a href=/pagehtml/{10}/{11}/{0}.html><img src='/{5}'  height='100' border=0 alt=''style='border:solid 1px #dfdfdf; padding:2px;' /></a></td>",
    /*模板4 行政区划图片首页调用*/   "{4}[详细请进]",
    /*模板5 走进井冈山魅力井冈山图片首页调用*/   "<td width='25%'><a href=/pagehtml/{10}/{11}/{0}.html><img src='/{5}'  height='100' border=0 alt=''style='border:solid 1px #dfdfdf; padding:2px;'></a></td>",
    /*模板6 走进井冈山首页调用*/   "<tr><td class='TextCsstype' style='PADDING-LEFT: 5px' valign='center' align='left'   height='26'><img height='10'  src='../images/imageInc.jpg' width='10'  align='absmiddle' border='0' /> <a title='{1}' href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td><td width='80' >[{8}]</td></tr>", 
            /*模板7 信息公开首页调用*/   "<tr><td class='TextCsstype' style='PADDING-LEFT: 5px' valign='center' align='left' height='26'><img height='10'  src='images/imageInc.jpg' width='10'  align='absmiddle' border='0' /> <a title='{1}' href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td><td width='100' class='datacss' >[{8}]</td></tr>",
         /*模板8 信息公开政府文件首页调用*/   "<tr><td class='TextCsstype' style='PADDING-LEFT: 5px' valign='center' align='left' height='26'><img height='10'  src='images/imageInc.jpg' width='10'  align='absmiddle' border='0' /> <a title='{1}' href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td></tr>",
        /*模板9 群众办事首页调用*/   "<tr><td  align='left' style='line-height:180%;height:25px;border-bottom:1px dashed #cdcdcd;padding-top:3px' ><img height='10'  src='/images/imageInc.jpg' width='10'  border='0' /> <a title='{1}'  href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td></tr>",
        /*模板10 走进井冈山首页调用*/   "<tr><td  valign='top' background='images/lei-2.jpg' style='padding-left:10px;padding-top:3px'><a href='{1}'>{2}</a></td></tr>", 
        /*模板11 公开信息 信息公开指南*/   "{4}<SPAN style='WIDTH: 100%; TEXT-ALIGN: right'><A class=red href='/pagehtml/{10}/{11}/{0}.html' target=_blank><STRONG>详细内容&gt;&gt;</STRONG></A></SPAN>",
         /*模板12 群众办事首页调用*/   "<tr><td  align='left' style='line-height:180%;height:22px;border-bottom:1px dashed #cdcdcd;' ><img height='10'  src='/images/imageInc.jpg' width='10'  border='0' /> <a title='{1}'  href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td></tr>",  
        /*模板13 调用*/   "<li  align='left' style=' list-style-type:none;line-height:180%;height:20px;padding-top:3px;padding-left:5px' > · <a title='{1}'  href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </li>",
            /*模板14 调用*/   "<tr><td  align='left' style='line-height:180%;height:25px;border-bottom:1px dashed #cdcdcd;padding-top:3px' ><img height='10'  src='/images/imageInc.jpg' width='10'  border='0' /> <a title='{1}'  href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td></tr>",
             /*模板15 调用*/   "<tr><td  align='left' style='line-height:180%;height:25px;border-bottom:1px dashed #cdcdcd;padding-top:3px' ><img height='10'  src='/images/imageInc.jpg' width='10'  border='0' /> <a title='{1}'  href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td></tr>"
        };
public string[] AlternatingTemplates = {
 /*模板0 井冈山要闻首页调用*/   "<tr><td class='TextCsstype' style='PADDING-LEFT: 5px' valign='center' align='left'  height='26'><img height='10'  src='images/imageInc.jpg' width='10'  align='absmiddle' border='0' /> <a title='{1}' href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td><td width='80' >[{8}]</td></tr>",
 /*模板1 政府文件首页调用*/   "<tr><td class='TextCsstype' style='PADDING-LEFT: 5px' valign='center' align='left'  height='26'><img height='10'  src='images/imageInc.jpg' width='10'  align='absmiddle' border='0' /> <a title='{1}' href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td><td width='80' >[{8}]</td></tr>",
    /*模板2 工作动态首页调用*/   "<li  align='left' style=' list-style-type:none;line-height:180%;height:20px;padding-top:3px;padding-left:5px' > · <a title='{1}'  href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </li>",
    /*模板3 魅力井冈山图片首页调用*/   "<td width='25%'><a href=/pagehtml/{10}/{11}/{0}.html><img src='GetThumbnail.aspx?fn={5}&tw=140&th=121' width='140' height='121' style='border:0px;' alt='' /></a></td>",
    /*模板4 行政区划图片首页调用*/   "{4}[详细请进]",
    /*模板5 走进井冈山魅力井冈山图片调用*/   "<td width='25%'><a href=/pagehtml/{10}/{11}/{0}.html><img src='/{5}'  height='100' border=0 alt=''style='border:solid 1px #dfdfdf; padding:2px;'></a></td>",
    /*模板6 走进井冈山首页调用*/   "<tr><td class='TextCsstype' style='PADDING-LEFT: 5px' valign='center' align='left'  height='26'><img height='10'  src='../images/imageInc.jpg' width='10'  align='absmiddle' border='0' /> <a title='{1}' href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td><td width='80' >[{8}]</td></tr>", 
    /*模板7 信息公开首页调用*/   "<tr><td class='TextCsstype' style='PADDING-LEFT: 5px' valign='center' align='left'  height='26'><img height='10'  src='images/imageInc.jpg' width='10'  align='absmiddle' border='0' /> <a title='{1}' href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td><td width='100'class='datacss'>[{8}]</td></tr>",
    /*模板8 信息公开政府文件首页调用*/   "<tr><td class='TextCsstype' style='PADDING-LEFT: 5px' valign='center' align='left'   height='26'><img height='10'  src='images/imageInc.jpg' width='10'  align='absmiddle' border='0' /> <a title='{1}' href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td></tr>",
    /*模板9 群众办事首页调用*/   "<tr style=''><td  align='left' style='line-height:180%; height:25px;border-bottom:1px dashed #cdcdcd;padding-top:3px'   ><img height='10'  src='/images/imageInc.jpg' width='10'   border='0' /> <a title='{1}'  href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td></tr>",
    /*模板10 走进井冈山首页调用*/   "<tr ><td  valign='top' background='images/lei-2.jpg'style='padding-left:10px;padding-top:3px'><a href='{1}'>{2}</a></td></tr>", 
        /*模板11 公开信息 信息公开指南*/   "{4}<SPAN style='WIDTH: 100%; TEXT-ALIGN: right'><A class=red href='/pagehtml/{10}/{11}/{0}.html' target=_blank><STRONG>详细内容&gt;&gt;</STRONG></A></SPAN>",
    /*模板12 群众办事首页调用*/   "<tr><td  align='left' style='line-height:180%;height:22px;border-bottom:1px dashed #cdcdcd;' ><img height='10'  src='/images/imageInc.jpg' width='10'  border='0' /> <a title='{1}'  href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td></tr>",
     /*模板13 调用*/   "<li  align='left' style=' list-style-type:none;line-height:180%;height:25px;border-bottom:1px dashed #cdcdcd;padding-top:3px' ><img height='10'  src='/images/imageInc.jpg' width='10'  border='0' /> <a title='{1}'  href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </li>",
    /*模板14 群众办事首页调用*/   "<tr style=''><td  align='left' style='line-height:180%; height:25px;border-bottom:1px dashed #cdcdcd;padding-top:3px'   ><img height='10'  src='/images/imageInc.jpg' width='10'   border='0' /> <a title='{1}'  href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td></tr>",
     /*模板15 调用*/   "<tr><td  align='left' style='line-height:180%;height:25px;border-bottom:1px dashed #cdcdcd;padding-top:3px' ><img height='10'  src='/images/imageInc.jpg' width='10'  border='0' /> <a title='{1}'  href='/pagehtml/{10}/{11}/{0}.html' target='_blank'>{2}</a> </td></tr>",

};
       
/* 模板代码结束 */

            protected void Page_Load(object sender, EventArgs e)
                {
                    string ArticleTypeId = GetQueryString("ArticleTypeId", "{A16D3EA3-6C37-4B17-9CF2-7798DF1C12A7}");
             int ISPopu =GetQueryInt("ISPopu", 0);
             int isImage = GetQueryInt("isImage", 0);
             int topnum = GetQueryInt("topnum", 10);
             int mid =GetQueryInt("template", 14);
               
                try
                {

                    Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
              string template = Templates[mid];
              string alternatingTemplate = AlternatingTemplates[mid];


                    T_axzf.BLL.Article bll_article = new Article();
                    T_axzf.BLL.ArticleType bll_articletype = new ArticleType();
                   
                   

                    string strWhere = "";
                    if (Convert.ToBoolean(ISPopu))
                    {
                        if (Convert.ToBoolean(isImage))
                        {
                            strWhere += "ISPopu=1 and ArticleImg!=''";
                        }
                        else
                        {
                            strWhere += "ISPopu=1";
                        }
                    }
                    else
                    {
                        if (Convert.ToBoolean(isImage))
                        {
                            strWhere += "ArticleImg!=''";
                        }
                    }
                    if (strWhere == "")
                    {
                        strWhere = " review=1";
                    }
                    else
                    {
                        strWhere = "review=1 and " + strWhere ;
                    }

                    if (ArticleTypeId != "{00000000-0000-0000-0000-000000000000}")
                    {
                        string articletypeidstring = bll_articletype.ShowCreateNode(ArticleTypeId, "");
                        strWhere += " and ArticleTypeID in(" + articletypeidstring + ") ";
                    }
                    DataTable dt=new DataTable();
                    if (mid == 12)
                    {
                       string parentidstr=bll_articletype.ShowCreateNode2("{4163B45A-7C40-4CDF-9614-A915DEA711B7}", "");

                       dt = bll_article.GetList(topnum, 1, "(TypeName = '服务指南') and review=1 AND (ParentTypeID in( " + parentidstr + ")").Tables[0];
                    }
                    else if (mid == 14)
                    {
                        dt = bll_article.GetList(topnum, 1, " review=1 AND ArticleTypeID in('45c7771e-9d17-4075-883d-c84c4e6d05ac','4d96f33f-b1ba-46af-a396-372a46fd1327','4621f809-ccdd-401a-9a05-0620d1e3b2ba','7bb1c994-3823-4191-bd97-3965d356322c','7302b678-f089-456c-8cff-a1008618536f','6f7a2431-2add-422a-bdd7-e19308235e26','c5d4625d-8839-48d7-a7ff-e655c98b82b0','f2c251f9-3e2c-4475-a7ac-d130a5d70d74','68e0b871-2236-46f5-bc19-368b9f7305ff','2e02616a-5fb8-4c57-be6d-168ef1449075','532a7aa4-a01e-4bf8-96e8-dcc74d7866d2','9fdb6fb4-6e9e-40b4-a381-22e4d433b265','5fee10ef-6ae9-4c1f-a345-a02eacb8dabd','834c2ca0-c6e3-4d60-bb25-e279a54c524c','64c9266c-6901-4eff-b444-689e9c22d83c','09776c64-4434-49c1-9733-a8296767138e')").Tables[0];
                    }
                    else if (mid == 15)
                    {
                        dt = bll_article.GetList(topnum, 1, " review=1 AND ArticleTypeID in('547fae26-a99a-4199-9a43-a1d5f573bd89','b8175bb3-b7e1-486d-8aa6-99eeecc574d7','a12948cc-337b-4674-95cb-0e487b88ba7d','73dc05cb-11ca-4ea9-b389-d5982d3c9f04','0e6b2202-9898-40d5-b18b-4647f8df5b93','aeb334d5-437b-4445-8dcf-ebfd996e6af2','9e1e3166-18fa-49c0-a4d0-f5f3b8df8c76','dbba882a-9120-4890-bb0d-746dc312ce7a','fdbb3e17-7681-4af4-a5b9-940b225f11d3','1d1eb2a3-ede5-4001-b4ac-22c521822308','f4446d0a-38e6-49e7-9bb9-01cf56532383','b672fdfd-2d2a-4a13-9e71-4a1f7eb0a048','858ec3e8-d952-4ffd-99f9-da7d55f48681','48efdd39-14b1-4729-9170-40b287dc817e','c464b2a0-59fe-4b23-8089-639a53462aa3','f774c2b6-3e34-4366-a194-65e55bea1dff')").Tables[0];
                    }


                    else
                    {
                        dt = bll_article.GetList(topnum, 1, strWhere).Tables[0];
                    }
                    OutPut(dt, template, alternatingTemplate);

                }
                catch
                {
                    Response.Write("document.write('参数错误,请检查!');");
                }
                finally
                {
                    Response.End();
                }
             
            }
          
            private void OutPut(DataTable dt, string template, string alternatingTemplate)
            {
             string result = "";
                //文章标题的长度
             int length =GetQueryInt("length", 13);
                //文章简介的长度
                int descriptlength = GetQueryInt("descriptlength", 1);
               
             int i = 0;
             foreach (DataRow dr in dt.Rows)
             {
              
              string title = dr["title"].ToString().Trim();
                    if (title.Length > length)
                        title = sFormat(title, length) + "...";

                    string title3 = dr["Articledescription"].ToString().Trim();
                    if (title3.Length > descriptlength)
                        title3 = sFormat(title3, descriptlength) + "...";
                   
                    string title2 = dr["Content"].ToString().Trim();


                    result += string.Format((i % 2 == 0 ? template : alternatingTemplate), dr["ArticleID"].ToString(), dr["Title"].ToString(), title, dr["Articledescription"].ToString(), title3, dr["ArticleImg"].ToString(), dr["ArticleTypeID"].ToString(), dr["Titlestyle"].ToString(), Convert.ToDateTime(dr["PublishTime"].ToString()).ToShortDateString(), title2, Convert.ToDateTime(dr["PublishTime"].ToString()).ToString("yyyy"), Convert.ToDateTime(dr["PublishTime"].ToString()).ToString("MM"));
              i++;
             }
             Response.Write("document.write('" + result.Replace("'", "\\'") + "');");
            }
            /// <summary>
            /// 获得指定Url参数的值
            /// </summary>
            /// <param name="strName">Url参数</param>
            /// <returns>Url参数的值</returns>
            public static string GetQueryString(string strName, string defaultvalue)
            {
                if (HttpContext.Current.Request.QueryString[strName] == null)
                {
                    return defaultvalue;
                }
                return HttpContext.Current.Request.QueryString[strName];
            }
            /// <summary>
            /// 获得指定Url参数的int类型值
            /// </summary>
            /// <param name="strName">Url参数</param>
            /// <param name="defValue">缺省值</param>
            /// <returns>Url参数的int类型值</returns>
            public static int GetQueryInt(string strName, int defValue)
            {
                if (HttpContext.Current.Request.QueryString[strName] == null)
                {
                    return defValue;
                }
                return Convert.ToInt32(HttpContext.Current.Request.QueryString[strName]);
            }
            //标题控制
            public string sFormat(string strProductName,int num)
            {
                if (strProductName.Length > num)
                {
                    return strProductName.Substring(0, num);
                }
                else
                {
                    return strProductName;
                }
            }

</script>

 

posted @ 2010-06-23 23:45  你妹的sb  阅读(542)  评论(0编辑  收藏  举报
百度一下