protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { MyClassOperate mco = new MyClassOperate(); } if (Convert.ToString(Session["admin"]) == "admin") { this.txtUsername.Visible = false; this.txtPassword.Visible = false; this.btnLogin.Visible = false; this.Label1.Visible = true; this.btnRevLogin.Visible = false; this.Label1.Text = "see you again!"; this.pnLogin.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { if (Convert.ToString(Session["admin"]) != "admin") { Response.Redirect("~/refresh.aspx?msg=" + "对不起,只有管理员才能登陆发表文章!"); return; } if (!IsPostBack) { this.Title = Title + SetTitle.getTitle(); MyClassOperate mop = new MyClassOperate(); this.DropDownListClass.DataSource = mop.getAllCidCname(); this.DropDownListClass.DataTextField = "cname"; this.DropDownListClass.DataValueField = "cid"; this.DropDownListClass.DataBind(); } }
protected void btnCommit_Click(object sender, EventArgs e) { MyClass mc = new MyClass(); mc.cname = this.txtCname.Text.Trim(); mc.description = this.txtDescription.Text.Trim(); MyClassOperate mop = new MyClassOperate(); if (mop.insert(mc)) { Response.Redirect("ClassManage.aspx"); Page.DataBind(); } else { this.lblExecuteSqlState.Text = "添加失败!"; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { MyClassOperate mco = new MyClassOperate(); this.DataListMyClass.DataSource = mco.viewAll(); this.DataListMyClass.DataBind(); } if (Convert.ToString(Session["admin"]) == "admin") { this.txtUsername.Visible = false; this.txtPassword.Visible = false; this.btnLogin.Visible = false; this.Label1.Visible = true; this.btnRevLogin.Visible = false; this.Label1.Text = "欢迎bob回家!"; this.pnLogin.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.Title = Title + SetTitle.getTitle(); try { int cid = Convert.ToInt32(Request.QueryString["cid"]); int currentPage; try { currentPage = Convert.ToInt32(Request.QueryString["p"]); } catch { currentPage = 1; } if (currentPage == 0) { currentPage = 1; } ArticleOperate aop = new ArticleOperate(); PagedDataSource ps = new PagedDataSource(); ps.DataSource = aop.viewAllByCid(cid); ps.AllowPaging = true; ps.PageSize = 20; ps.CurrentPageIndex = currentPage - 1; this.Pagination1.currentPage = currentPage; this.Pagination1.pageCount = ps.PageCount; this.Pagination1.pageUrl = "list.aspx?cid=" + cid; this.Pagination1.paramName = "p"; MyClassOperate mop = new MyClassOperate(); this.Page.Title = (mop.getByCid(cid)).cname + this.Page.Title; this.DataListArticleList.DataSource = ps; this.DataListArticleList.DataBind(); } catch { Response.Redirect("refresh.aspx?msg=" + "对不起没有此分类的信息"); } } }
protected void Page_Load(object sender, EventArgs e) { if (Convert.ToString(Session["admin"]) != "admin") { Response.Redirect("~/refresh.aspx?msg=" + "对不起,只有管理员才能对文章进行相关的操作!"); return; } if (!IsPostBack) { this.Title = Title + SetTitle.getTitle(); MyClassOperate mop = new MyClassOperate(); this.DropDownListClass.DataSource = mop.getAllCidCname(); this.DropDownListClass.DataTextField = "cname"; this.DropDownListClass.DataValueField = "cid"; this.DropDownListClass.DataBind(); try { int aid = Convert.ToInt32(Request.QueryString["aid"]); Article at = (new ArticleOperate()).getByAid(aid); if (at == null || at.Equals(null)) { this.lblcontext.Text = "对不起,此文章不存在,或被管理员删除"; } else { this.txtTitle.Text = at.title; Page.Title = at.title + Title; this.DropDownListClass.SelectedValue = at.cid.ToString(); this.txtBody.Value = at.content; } } catch { Response.Redirect("~/refresh.aspx?msg=" + "此文章不存在,或被管理员删除,请见谅!"); } } }