📄 post.aspx.cs
字号:
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;
namespace bbs
{
/// <summary>
/// post 的摘要说明。
/// </summary>
public class post : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button_send;
protected System.Web.UI.WebControls.Label Label_UN;
protected System.Web.UI.WebControls.Literal Literal_UserName;
protected System.Web.UI.WebControls.TextBox TextBox_title;
protected System.Web.UI.WebControls.TextBox TextBox_Content;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.Button Button_Clear;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
this.Literal_UserName.Text=Session["username"].ToString();
if(Session["username"]==null || Session["username"].ToString()=="")
{
Response.Redirect("error.aspx");
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button_send.Click += new System.EventHandler(this.Button_send_Click);
this.Button_Clear.Click += new System.EventHandler(this.Button_Clear_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button_send_Click(object sender, System.EventArgs e)
{
if (this.TextBox_title.Text=="")
{
Response.Write("<script>alert('***主题不能为空!')</script>");
}
else if (this.TextBox_Content.Text=="")
{
Response.Write("<script>alert('***发表的内容不能为空!')</script>");
}
else if(this.TextBox_title.Text.Length>100)
{
Response.Write("<script>alert('***对不起,你输入的主题过长!')</script>");
}
else if(this.TextBox_Content.Text.Length<6)
{
Response.Write("<script>alert('***对不起,字数不能少于6!')</script>");
}
else
{
string title;
if(this.DropDownList1.SelectedValue.ToString()=="[选择话题]")
{
title=this.TextBox_title.Text;
}
else
{
title=this.DropDownList1.SelectedItem.Text+this.TextBox_title.Text;
}
string userid=Session["userid"].ToString();
string sql="insert into tbBbs (sBbsHead,sBbsContent,dBbsDate,iUserID_FK) values('"+title+"','"+this.TextBox_Content.Text+"','"+DateTime.Now+"','"+userid+"')";
da.da d=new da.da();
d.command(sql);
string sql2="update users set iBbscount=iBbscount+1 where iUserID='"+userid+"'";
da.da q=new da.da();
q.command(sql2);
Response.Redirect("index.aspx");
}
}
private void Button_Clear_Click(object sender, System.EventArgs e)
{
this.TextBox_Content.Text=null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -