addBlog.aspx
<%@ Page language="c#" Codebehind="addBlog.aspx.cs" AutoEventWireup="false" Inherits="blog.admin.addBlog" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>add</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<LINK href="../inc/style.css" type="text/css" rel="stylesheet">
</HEAD>
<body>
<form runat="server">
<table cellSpacing="0" cellPadding="0" width="760" align="center" border="0">
<tr>
<td width="180" bgColor="#999999"> <FONT face="宋体"> </FONT>
</td>
<td width="580">
<table cellSpacing="0" cellPadding="0" width="100%" align="right" border="0">
<tr>
<td align="right" width="18%" height="30">所属分类:</td>
<td width="82%"><asp:dropdownlist id="kindBlog" runat="server"></asp:dropdownlist></td>
</tr>
<tr>
<td align="right" height="30">Blog标题:</td>
<td><asp:textbox id="titleBlog" runat="server"></asp:textbox></td>
</tr>
<tr>
<td align="right" height="30">Blog摘要:</td>
<td><asp:textbox id="summaryBlog" runat="server" Height="64px" Width="464px" TextMode="MultiLine"></asp:textbox></td>
</tr>
<tr>
<td align="right">Blog正文:</td>
<td height="300"><asp:textbox id="textBlog" runat="server" Height="288px" Width="464px" TextMode="MultiLine"></asp:textbox></td>
</tr>
<tr>
<td align="right" height="50">上传附件:</td>
<td> <FONT face="宋体">updata</FONT></td>
</tr>
<tr>
<td align="right" height="30">发布选项:</td>
<td></td>
</tr>
<tr>
<td align="right">定时发布:</td>
<td> </td>
</tr>
<tr>
<td align="right" height="30"> </td>
<td>
<asp:button id="up" runat="server" Text="提交"></asp:button></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</HTML>
addBlog.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace blog.admin
{
/// <summary>
/// addBlog 的摘要说明。
/// </summary>
public class addBlog : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList kindBlog;
protected System.Web.UI.WebControls.TextBox titleBlog;
protected System.Web.UI.WebControls.TextBox summaryBlog;
protected System.Web.UI.WebControls.TextBox textBlog;
protected System.Web.UI.WebControls.Button up;
protected System.Data.SqlClient.SqlConnection sqlConnectionBlog;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.sqlConnectionBlog = new System.Data.SqlClient.SqlConnection();
//
// sqlConnectionBlog
//
this.sqlConnectionBlog.ConnectionString = "workstation id=\"YT-ESHAKA\";packet size=4096;user id=sa;data source=\"YT-ESHAKA\";pe" +
"rsist security info=True;initial catalog=blog;password=shaka";
this.up.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
string strInsert;
SqlCommand cmdInsert;
strInsert = "Insert blog ( titleBlog ) Values ( @titleBlog )";
cmdInsert = new SqlCommand( strInsert, sqlConnectionBlog );
cmdInsert.Parameters.Add( "@titleBlog", SqlDbType.VarChar ).Value = titleBlog.Text;
sqlConnectionBlog.Open();
cmdInsert.ExecuteNonQuery();
sqlConnectionBlog.Close();
}
}
}
总是存不进去