示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {

        string tmpl = @"
                <tr>
                    <td height='25' align='left' valign='middle'>
                        <a href='Info.aspx?type=news&id={0}' target='_blank' title='标题:{1}'>{1}
                        </a>
                    </td>
                    <td width='80' align='center' valign='middle'>
                        {2}
                    </td>
                </tr>
           ";
        string toptitle = "<a href='Info.aspx?type=news&id={0}' target='_blank' title='标题:{1}'><font class='red18'>顶条:{1}</font></a>";
        string topdetail = "<a href='Info.aspx?type=news&id={0}' target='_blank' title='标题:{1}'>{1} </a>";
        if (!IsPostBack)
        {
            List<news> lst = new List<news>();
            newsManager mgr = new newsManager();
            string result = string.Empty;
            lst = mgr.GetnewsListImage(6);
            foreach (news model in lst)
            {
                if (model.title.Length > 20)
                {
                    model.title = model.title.Substring(0, 20);
                }
                result += string.Format(tmpl, model.id, model.title, Convert.ToDateTime(model.addtime).ToString("yyyy-MM-dd"));
            }
            result = "<table width='100%' border=0 align='center' cellpadding='0' cellspacing='0'>" + result + " </table>";
            news_wrap.InnerHtml = result;
            lst = mgr.GetTopNews();
            string orgtitle = lst[0].title;
            if (lst[0].title.Length > 12)
            {
                lst[0].title = lst[0].title.Substring(0, 12) + "...";
            }
            titlte_wrap.InnerHtml = string.Format(toptitle, lst[0].id, lst[0].title);
            desc_wrap.InnerHtml = string.Format(topdetail, lst[0].id, orgtitle);

        }

    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            List<news> lst = new List<news>();
            newsManager mgr = new newsManager();
            string tmpl = @" 
            <a href='Info.aspx?type=news&id={0}' target='_blank'>
                <img src='ImgUpload\{1}' alt='{2}' width='355'height='235' />
            </a>";
            string result = string.Empty;
            lst = mgr.GetnewsListImage();
            foreach (news model in lst)
            {
                result += string.Format(tmpl, model.id, model.fimgurl, model.title);
            }
            KinSlideshow.InnerHtml = result;



        }
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            string tmpl = @"<table width='98%' border='0' align='center' cellpadding='0' cellspacing='0' class='dx'
                    onmouseover='this.bgColor='#FFFF66';' onmouseout='this.bgColor='#FFFFFF';' bgcolor='#ffffff'>
                    <tr>
                        <td width='35' height='40' align='center'>
                            <img src='images/txt.png' alt='图标' />
                        </td>
                        <td align='left' class='p14'>
                            <a href='{3}' target='_blank' title='{0}'><font class='p14'>{2}</font></a>
                        </td>
                        <td width='110' align='left'>
                            <!--浏览:次-->
                        </td>
                        <td width='140' align='left'>
                            发稿:{1}
                        </td>
                    </tr>
                </table>";

            string pagetmpl=@"
            <table border='0' align='center'>
                    <form onsubmit='document.location = {7}+ this.page.value;return false;'method='get'>
                    <tbody>
                        <tr>
                            <td align='right'>
                                <p align='center'>
                                    <a href='{0}'> 首页</a>
                                    <a href='{1}'>上一页</a>
                                    <a href='{2}'>下一页</a>
                                    <a href='{3}'>尾页</a>
                                    页次:{4}/{5}页 
                                    共有{6}条 
                                    转到
                                    <input value='1' maxlength='5' size='1' id='page' name='page' type='TEXT'>页
                                    <input style='font-size: 9pt' class='b2' value='GO' type='button' onclick='window.location.href={7}+document.getElementById({8}).value;'></p>
                            </td>
                        </tr>
                    </form>
                    </TBODY></table>";
              if (!IsPostBack)
            {
                try
                {
                    string res = string.Empty;
                    string type = Request.QueryString.Get("type");
                    string page=Request.QueryString.Get("page");
                    string lb = Request.QueryString.Get("sid");
                    if(string.IsNullOrEmpty(page))
                    {
                        page="1";
                    }
                    string keyword=Request.QueryString.Get("keyword");

                    newsManager mgr=new newsManager();
                    int pagecount=0;
                    int allcount=0;
                    DataTable dt=new DataTable();
                    WhereClip where = new WhereClip();
                    if (type != null)
                    {
                        where = where && ViewAllInfo._.contentType == type;
                    }
                    if (lb != null)
                    {
                        where = where && ViewAllInfo._.sid == lb;
                    }
                    if (keyword != null)
                    {
                        where = where && ViewAllInfo._.title == keyword;
                    }
                    dt = mgr.GetViewAllInfoDataTable(int.Parse(page), 20, " addtime desc ", ref pagecount, ref allcount, where);

                    foreach(DataRow row in dt.Rows)
                    {
                        string title = row["title"].ToString();
                        if (title.Length > 28)
                        {
                            title = title.Substring(0, 28)+"...";
                        }
                        res += string.Format(tmpl, row["title"].ToString(), row["addtime"].ToString(), title, "Info.aspx?id=" + row["id"].ToString() + "&type=" + type);
                    }
                    string urlprefix="Category.aspx?type="+type+"&sid="+lb+"&page=";
                    int cur=int.Parse(page);
                    string first    =urlprefix+"1";
                    string next = urlprefix + ((cur + 1) > pagecount ? pagecount : (cur + 1)).ToString();
                    string pre      =urlprefix+((cur-1)<1?"1":(cur-1).ToString());
                    string last     =urlprefix+pagecount.ToString();
                    res += string.Format(pagetmpl, first, pre, next, last, page, pagecount.ToString(), dt.Rows.Count.ToString(),"\""+ urlprefix+"\"","\"page\"");
                    OutStr =res;
                   // OutStr = string.Format(tmpl, res);
                }
                catch (Exception)
                {
                    OutStr = string.Format(tmpl, "");
                }
 
            }
        }
示例#4
0
    private void GenerSpeciInfo()
    {

        List<news> list = new newsManager().GetClassID(ClassID);

        StringBuilder sb = new StringBuilder(string.Format(@"<table height='210' width='363' width='363' border='0' cellpadding='0' cellspacing='0'
                                class='kk'>
                                <tr>
                                    <td align='center' valign='top'>
                                        <table width='100%' border='0' cellpadding='0' cellspacing='0' background='images/nzcms/news_bg.gif'>
                                            <tr>
                                                <td width='25' height='29' align='center' class='white12B'>
                                                    <img src='images/nzcms/nzcms_bh.gif' alt='标识' />
                                                </td>
                                                <td width='250' align='left' class='white14B'>
                                                    {0}
                                                </td>
                                                <td align='right' class='p12'>
                                                    <a href='{1}'  target='_blank'>更多&gt;&gt;&gt;</a>&nbsp;&nbsp;
                                                </td>
                                            </tr>
                                        </table>
                                        <table width='99%' height='24' border='0' align='center' cellpadding='0' cellspacing='0'>", Title, "Category.aspx?type=news&sid=" + ClassID));
        foreach (news item in list)
        {
            string temTitle = item.title;
            if (item.title.Length > 20)
            {
                temTitle = item.title.Substring(0, 20) + "...";
            }
            sb.AppendFormat(@"<tr>
                                                <td height='25' align='left' valign='middle'>
                                                    &nbsp;·&nbsp;<a href='Info.aspx?type=news&id={0}' target='_blank' title='标题:{1}'>{3}</a>
                                                    <font class='red'>★</font>
                                                </td>
                                                <td width='70' align='center' valign='middle'>
                                                    {2}
                                                </td>
                                            </tr>", item.id, item.title, item.addtime.Value.ToString("MM月:dd日"), temTitle);
        }
        sb.Append("</table> </td> </tr>  </table>");
        OutStr = sb.ToString();



    }
示例#5
0
    private void GenerHotNews()
    {

        string temlate = @"
           <table width='96%' height='250' border='0' cellpadding='0' cellspacing='0' bordercolor='#FFFFFF'
                    background='images/bg/01.gif' class='kk22'>
                    <tr>
                        <td valign='top'>
                            <table width='100%' border='0' cellpadding='0' cellspacing='0'>
                                <tr>
                                    <td width='90' height='28' align='center' background='images/left.gif' class='title14b'>
                                        {0}
                                    </td>
                                    <td align='right' background='images/left2.gif'>
                                        <img src='images/HOT.gif' />
                                    </td>
                                </tr>
                            </table>
                            <table width='98%' height='24' border='0' align='center' cellpadding='0' cellspacing='0'>";
        string listTeml = @" <tr>
                                    <td height='27' align='left' valign='middle'>
                                        &nbsp;<img src='images/HOT2.gif' width='7' height='7' />&nbsp;<a href='Info.aspx?type=news&id={0}'
                                            target='_blank' title='标题:{1}'>{2}</a>
                                    </td>
                                </tr> ";
        StringBuilder sb = new StringBuilder();
        sb.AppendFormat(temlate, "热点文章");
        List<news> list = new newsManager().GetHotNews();
        foreach (news item in list)
        {
            string title = item.title;
            if (title.Length > 17)
            {
                title = title.Substring(0, 17) + "...";
            }
            sb.AppendFormat(listTeml, item.id, item.title, title);
        }


        sb.Append(@"</table>
                        </td>
                    </tr>
                </table>
                <table height='5' border='0' cellpadding='0' cellspacing='0'>
                    <tr>
                        <td>
                        </td>
                    </tr>
                </table>");
        OutStr = sb.ToString();
    }
    public string getHtmlFromTypeID(string tid)
    {
        WhereClip where = new WhereClip();
        where = where && newclass._.id == tid;//看看parentid是他的有没有
        newclass model = new newclass();
        newsManager mgr = new newsManager();
        model = mgr.GetItemById(where);


        WhereClip where2 = new WhereClip();
        where2 = where2 && newclass._.id == model.pid;//看看parentid是他的有没有
        newclass modelparent = new newclass();
        modelparent = mgr.GetItemById(where2);
        string res = string.Empty;
        if (modelparent != null)
        {
            res = string.Format(@"<a href='Category.aspx?sid={0}'>{1}</a>&nbsp;&gt;&nbsp;&nbsp;
                       <a href='Category.aspx?sid={2}'>{3}</a>", modelparent.id, modelparent.classname, model.id, model.classname);

        }
        else
        {

            res = string.Format(@"<a href='Category.aspx?sid={0}'>{1}</a>", model.id, model.classname);

        }
        return res;
    }
    public string getNewsNav()
    {
        string res = string.Empty;
        string lb = Request.QueryString.Get("sid");
        string newsid = Request.QueryString.Get("id");
        newsManager mgr = new newsManager();
        if (!string.IsNullOrEmpty(newsid))
        {
            WhereClip where = new WhereClip();

            where = where && news._.id == lb;
            news model = new news();
            model = mgr.GetnewsItemById(where);
            string typeid = model.sid.ToString();
            res = getHtmlFromTypeID(typeid);
            //根据新闻找到 新闻的上一级
        }
        else
        {
            res = getHtmlFromTypeID(lb);
            //看看该分类有没有上一级
        }
        return res;

    }