国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

利用c#制作簡(jiǎn)單的留言板 (2)

2024-07-21 02:20:21
字體:
供稿:網(wǎng)友
myconn.cs
namespace notpage
{
    using system;
    using system.data.sql ;

    /// <summary>
    ///    summary description for myconn.
    /// </summary>
    public class myconn:system.data.sql.sqlconnection
    {
        private void initializecomponent ()
        {
        }
    
        public myconn()
        {
            //
            // todo: add constructor logic here
            //
            this.database = "back" ;
            this.datasource = "luochang" ;
            this.userid = "sa" ;
            this.password = "" ;
        }
    }
}
添加留言addtopic.aspx
<%@ page language="c#" codebehind="addtopic.cs" autoeventwireup="false" inherits="notpage.addtopic" %>
<html><head>
<meta content="microsoft visual studio 7.0" name=generator>
<meta content=c# name=code_language></head>
<body>
<form method=post runat="server">
<table cellspacing=1 cellpadding=1 width="88%" border=0>
  <tr>
    <td>留言主題:</td>
    <td><asp:textbox id=txttitle runat="server" maxlength="80" columns="65"></asp:textbox></td></tr>
  <tr>
    <td>姓名:</td>
    <td><asp:textbox id=txtauthor runat="server" maxlength="40" columns="20"></asp:textbox></td></tr>
  <tr>
    <td>留言內(nèi)容</td>
    <td><asp:textbox id=txtcontent runat="server" maxlength="2000" columns="50" rows="20" textmode="multiline"></asp:textbox><asp:button
      id=btnsubmit runat="server"
  text="確認(rèn)"></asp:button></td></tr></table></form>
    
  </body></html>

對(duì)應(yīng)的cs
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 addtopic.
    /// </summary>
    public class addtopic : system.web.ui.page
    {
        protected system.web.ui.webcontrols.textbox txtcontent;
        protected system.web.ui.webcontrols.textbox txtauthor;
        protected system.web.ui.webcontrols.textbox txttitle;
        protected system.web.ui.webcontrols.button btnsubmit;
    
    public addtopic()
    {
        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();
        }

        /// <summary>
        ///    required method for designer support - do not modify
        ///    the contents of this method with the code editor.
        /// </summary>
        private void initializecomponent()
        {
            btnsubmit.click += new system.eventhandler (this.onsubmit);
            this.load += new system.eventhandler (this.page_load);
        }
        public void onsubmit(object sender , eventargs e)
        {
            
            
            if (page.isvalid)
            {
                //數(shù)據(jù)入庫
                try
                {
            
                    notepage objnp = new notepage();
                    objnp.title = txttitle.text;
                    objnp.author = txtauthor.text;
                    objnp.content = txtcontent.text;
                    objnp.adddate = system.datetime.now;
                    notepage objnp1 = new notepage();
                    if(objnp1.addtopic(objnp))
                    {
                        
                        response.write ("<p align=center class=cn>成功留言,點(diǎn)擊<a href = list.aspx>此處</a>查看留言列表!。</p>") ;
                    }
                }
                catch(exception exp)
                {
#if debug
                    response.write ("出現(xiàn)異常:" + exp.message) ;
                    return ;
#endif//debug
                
                }
            }
            
            
        }

    }
}

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 镇原县| 维西| 布尔津县| 通江县| 宽甸| 卢氏县| 铁力市| 玉树县| 黄骅市| 昌图县| 土默特右旗| 孟州市| 当涂县| 旅游| 图木舒克市| 盐津县| 孙吴县| 崇左市| 正定县| 泸州市| 正蓝旗| 贵溪市| 晋宁县| 达日县| 曲麻莱县| 房山区| 林芝县| 天镇县| 石狮市| 绥化市| 江达县| 濮阳县| 特克斯县| 台湾省| 江津市| 临清市| 沅陵县| 西吉县| 临湘市| 韶山市| 瑞昌市|