欢迎光临
我们一直在努力

利用c#制作简单的留言板 (3)-.NET教程,C#语言

建站超值云服务器,限时71元/月

显示列表list.aspx
<%@ page language="c#" codebehind="list.cs" autoeventwireup="false" inherits="notpage.list" %>
<html><head>
    <meta name="generator" content="microsoft visual studio 7.0">
    <meta name="code_language" content="c#"></head>
  <body>
    
    <form method="post" runat="server">

     </form><a href = "addtopic.aspx">发表留言</a><br>
    <table width="90%" height="1" border="0" cellspacing="2" cellpadding="2" id=liuyan>
    <tr>
        <td>主题</td>
        <td>留言人</td>
        <td>留言时间</td>
    </tr>
    
        <asp:label id="n_tdtitle" runat=server></asp:label>
    
</table>

  </body></html>
namespace notpage
{
    using system;
    using system.collections;
    using system.componentmodel;
    using system.data;
    using system.drawing;
    using system.web;
    using system.web.sessionstate;
    using system.web.ui;
    using system.web.ui.webcontrols;
    using system.web.ui.htmlcontrols;

        

    /// <summary>
    ///    summary description for list.
    /// </summary>
    public class list : system.web.ui.page
    {
        protected system.web.ui.webcontrols.label n_tdtitle;
    
    public list()
    {
        page.init += new system.eventhandler(page_init);
        }

        protected void page_load(object sender, eventargs e)
        {
            if (!ispostback)
            {
                //
                // evals true first time browser hits the page
                //
            }
        }

        protected void page_init(object sender, eventargs e)
        {
            //
            // codegen: this call is required by the asp+ windows form designer.
            //
            initializecomponent();
            init_tdtitle();
    

        }
        

        /// <summary>
        ///    required method for designer support – do not modify
        ///    the contents of this method with the code editor.
        /// </summary>
        private void initializecomponent()
        {
            this.load += new system.eventhandler (this.page_load);
        }
        
        protected void init_tdtitle()
        {
             initializecomponent();
            //
            // codegen: this call is required by the asp+ windows form designer.
            //
            try
            {    
                notepage np = new notepage();

                arraylist arrtopic = np.gettopiclist();
            
                for ( int i = 0 ; i < arrtopic.count  ; i ++)
                {    
                    notepage objtopic = (notepage)arrtopic[i] ;
                    string str ="<tr><td><a href = showtopic.aspx?id="+objtopic.id.tostring()+">" + objtopic.title.tostring() + "</a></td>";
                    str = str +"<td>" + objtopic.author.tostring()+"</td>";
                    str = str +"<td>" + objtopic.adddate.tostring()+"</td></tr>";
                    n_tdtitle.text = str  + n_tdtitle.text;
                }
            }
            catch(exception e)
            {
                throw(new exception("取得贴子列表出错:" + e.tostring())) ;
            }

        }
    }
}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 利用c#制作简单的留言板 (3)-.NET教程,C#语言
分享到: 更多 (0)