index.aspx.cs
来自「asp做的新闻系统」· CS 代码 · 共 105 行
CS
105 行
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
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 Web
{
public class index : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TxtUserName;
protected System.Web.UI.WebControls.Button BtnOK;
protected System.Web.UI.WebControls.TextBox TxtPwd;
protected System.Web.UI.WebControls.Button BtnRegister;
DataAccess.DataAccess Das = new DataAccess.DataAccess();
private void Page_Load(object sender, System.EventArgs e)
{
BtnOK.Attributes.Add("onclick","javascript:return CheckInput();");
BtnRegister.Attributes.Add("onclick","javascript:return openwin('user/register.aspx?Flag=0');");
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.BtnOK.Click += new System.EventHandler(this.BtnOK_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void BtnOK_Click(object sender, System.EventArgs e)
{
OleDbDataReader read = Das.GetDataReader("select username from users where username='" + TxtUserName.Text.Trim() + "' and pwd='" + TxtPwd.Text.Trim() + "'");
if(read.Read())
{
Session["UserName"] = read[0].ToString();
TxtUserName.Text = "";
TxtPwd.Text = "";
}
else
{
Response.Write("<script language='javascript'>alert('用户名或密码不正确,请重新输入!');</script>");
}
}
public void Login()
{
try
{
if((Session["UserName"].ToString() != null) && (Session["UserName"].ToString() != ""))
{
Response.Write("<a href='#' onclick=openwin('user/unregister.aspx');location.reload();>注销</a> ");
Response.Write("<a href='#' onclick=openwin('user/Register.aspx?Flag=1');>个人管理</a>");
}
}
catch
{
}
}
public void GetArticle()
{
Response.Write("<table height='66' cellSpacing='2' cellPadding='0' border='0'>");
OleDbDataReader read = Das.GetDataReader("select top 10 id,title from article order by id desc");
while(read.Read())
{
Response.Write("<tr><td height ='20' vAlign='top'>·<A href='#' onclick =openwin('ArticleInfo.aspx?id=" + read[0].ToString() +"')>" + read[1].ToString() + "</A></td></tr>");
}
Response.Write("</table>");
}
public void GetForum()
{
Response.Write("<table cellSpacing='4' cellPadding='0' border='0' width='100%'>");
OleDbDataReader read = Das.GetDataReader("select top 10 boardid,title from forum where replyboardid=0 order by boardid desc");
while(read.Read())
{
Response.Write("<tr><td height ='20' vAlign='top'>·<A target='_blank' href='Forum/View.aspx?BoardID=" + read[0].ToString() +"')>" + read[1].ToString() + "</A></td></tr>");
}
Response.Write("</table>");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?