資源簡介
基于c#的簡單新聞發布系統源碼(帶數據庫),含有前臺和后臺,有添加、刪除、修改等功能。

代碼片段和文件信息
using?System;
using?System.Data;
using?System.Data.SqlClient;
using?System.IO;
using?System.Web.UI;
using?System.Web.UI.WebControls;
using?System.Web.UI.HtmlControls;
namespace?news
{
????///?
????///?AddNew?的摘要說明。
????///?
????public?partial?class?Add?:?System.Web.UI.Page
????{
????????protected?System.Web.UI.WebControls.DataGrid?dg;
????????protected?System.Web.UI.WebControls.Button?Button3;
????????protected?System.Web.UI.WebControls.TextBox?TextBox1;
????????protected?System.Web.UI.WebControls.DropDownList?DropDownList1;
????????protected?System.Web.UI.WebControls.Button?Button1;
????????protected?System.Web.UI.WebControls.linkButton?btnFirst;
????????protected?System.Web.UI.WebControls.linkButton?btnPrev;
????????protected?System.Web.UI.WebControls.linkButton?btnNext;
????????protected?System.Web.UI.WebControls.linkButton?btnLast;
????????protected?System.Web.UI.WebControls.Label?lblCurrentPage;
????????protected?System.Web.UI.WebControls.Label?lblPageCount;
????????protected?System.Web.UI.WebControls.Label?lblRecordCount;
????????protected?System.Web.UI.WebControls.TextBox?txtIndex;
????????protected?System.Web.UI.WebControls.Label?Span1;
????????protected?void?Page_Load(object?sender?EventArgs?e)
????????{
????????}
????????#region?Web?窗體設計器生成的代碼
????????override?protected?void?OnInit(EventArgs?e)
????????{
????????????//
????????????//?CODEGEN:?該調用是?ASP.NET?Web?窗體設計器所必需的。
????????????//
????????????InitializeComponent();
????????????base.OnInit(e);
????????}
????????///?
????????///?設計器支持所需的方法?-?不要使用代碼編輯器修改
????????///?此方法的內容。
????????///?
????????private?void?InitializeComponent()
????????{
????????}
????????#endregion
????????//響應單擊“清除”事件,清空輸入項
????????protected?void?btnCancel_Click(object?sender?System.EventArgs?e)
????????{
????????????txttitle.Text?=?““;
????????????txtContent.Text?=?““;
????????????txtAuthor.Text?=?““;
????????}
????????//響應單擊“確定”事件,保存添加的新聞
????????protected?void?btnOk_Click(object?sender?System.EventArgs?e)
????????{
????????????//檢驗用戶輸入是否合法
????????????if?(txttitle.Text?==?““?||?txtContent.Text?==?““?||?txtAuthor.Text?==?““)
????????????{
????????????????Label1.Text?=?“標題、內容、作者等不能為空!“;
????????????????return;
????????????}
????????????if?(txttitle.Text.Length?>?50)
????????????{
????????????????Label1.Text?=?“你的標題太長了!“;
????????????????return;
????????????}
????????????//保存上傳文件
????????????String?filePath?=?Server.MapPath(“image\\“?+?Path.GetFileName(FileUpload1.PostedFile.FileName));
????????????if?(File.Exists(filePath))
????????????{
????????????????Response.Write(“ript?language=javascript>?alert(‘上傳文件重名,請改名后再上傳!‘); ript>?“);
????????????????return;
????????????}
????????????else
????????????{
????????????????if?(FileUpload1.HasFile)
????????????????{
????????????????????FileUpload1.PostedFile.SaveAs(filePath);
????????????????}
????????????????//更新數據庫,保存新聞信息
??
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-05-23?11:03??news\
?????文件????????2046??2010-12-26?15:42??news\AddNews.aspx
?????文件????????4207??2010-12-26?15:42??news\AddNews.aspx.cs
?????目錄???????????0??2010-12-27?08:06??news\App_Code\
?????文件????????2115??2010-12-26?15:42??news\App_Code\AssemblyInfo.cs
?????文件????????1679??2010-12-26?15:42??news\App_Code\DbHelper.cs
?????文件????????1372??2010-12-26?15:42??news\App_Code\Global.asax.cs
?????目錄???????????0??2010-12-27?08:06??news\App_Themes\
?????目錄???????????0??2010-12-27?08:06??news\App_Themes\theme1\
?????文件??????????53??2010-12-26?15:42??news\App_Themes\theme1\st
?????目錄???????????0??2010-12-27?08:06??news\databa
?????文件?????1441792??2010-12-26?15:42??news\databa
?????文件?????1048576??2010-12-26?15:42??news\databa
?????文件????????2080??2010-12-26?15:42??news\Default.aspx
?????文件????????1262??2010-12-26?15:42??news\Default.aspx.cs
?????文件??????????57??2010-12-26?15:42??news\Global.asax
?????目錄???????????0??2010-12-27?08:06??news\Image\
?????文件??????406256??2010-12-26?15:42??news\Image\0302_10.jpg
?????文件??????166259??2010-12-26?15:42??news\Image\14545900.jpg
?????文件???????????0??2010-12-26?15:42??news\Image\2
?????文件??????????55??2010-12-26?15:42??news\Image\dot-postiont2.gif
?????文件?????????338??2010-12-26?15:42??news\Image\dot_replay.gif
?????文件?????????107??2010-12-26?15:42??news\Image\error.txt
?????文件?????????281??2010-12-26?15:42??news\Image\error2.txt
?????文件?????????433??2010-12-26?15:42??news\Image\FACardGroup.txt
?????文件???????15737??2010-12-26?15:42??news\Image\fish089.JPG
?????文件?????????321??2010-12-26?15:42??news\Image\gototop2.gif
?????文件???????16648??2010-12-26?15:42??news\Image\inst004.gif
?????文件????????2672??2010-12-26?15:42??news\Image\mb.gif
?????文件????????9847??2010-12-26?15:42??news\Image\natu100.gif
?????文件????????5231??2010-12-26?15:42??news\Image\sample52.gif
............此處省略13個文件信息
- 上一篇:基于c#編寫的五子棋小游戲
- 下一篇:ACTIVE MQ通訊實現
評論
共有 條評論