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

首頁 > 開發 > 綜合 > 正文

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

2024-07-21 02:17:54
字體:
來源:轉載
供稿:網友
myconn.cs
namespace notpage
{
using system;
using system.data.sql ;</p><p> /// <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>留言內容</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="確認"></asp:button></td></tr></table></form>

</body></html></p><p>對應的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;</p><p> /// <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);
}</p><p> protected void page_load(object sender, eventargs e)
{
if (!ispostback)
{
//
// evals true first time browser hits the page
//
}
}</p><p> protected void page_init(object sender, eventargs e)
{
//
// codegen: this call is required by the asp+ windows form designer.
//
initializecomponent();
}</p><p> /// <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)
{
//數據入庫
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>成功留言,點擊<a href = list.aspx>此處</a>查看留言列表!。</p>") ;
}
}
catch(exception exp)
{
#if debug
response.write ("出現異常:" + exp.message) ;
return ;
#endif//debug

}
}


}</p><p> }
}

商業源碼熱門下載www.html.org.cn

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 北辰区| 上思县| 休宁县| 彰化市| 乌拉特前旗| 汝城县| 五常市| 沽源县| 焉耆| 焦作市| 塘沽区| 东莞市| 涡阳县| 仁怀市| 临漳县| 大名县| 资溪县| 华容县| 宝兴县| 乌什县| 东平县| 临颍县| 龙川县| 精河县| 治多县| 自贡市| 新郑市| 襄城县| 商河县| 大同县| 山东| 内乡县| 澳门| 兰州市| 城市| 溧水县| 五家渠市| 八宿县| 桓台县| 二连浩特市| 龙岩市|