protected void pageGridView_RowUpdating(object sender, GridViewUpdateEventArgs e) { long idx = long.Parse(e.Keys[0].ToString()); BizPage.UpdatePageByID(idx, e.NewValues["PageTitle"].ToString(), e.NewValues["Memo"].ToString()); pageGridView.EditIndex = -1; FreshData(this.aspNetPager.CurrentPageIndex - 1); }
protected void vldExistedPage_ServerValidate(object source, ServerValidateEventArgs args) { var res = BizPage.GetPageByTitle(args.Value.Trim().Replace(" ", "")); if (res != null) { args.IsValid = false; } else { args.IsValid = true; } }
protected void btnOK_Click(object sender, EventArgs e) { BizPage.AddNewPage(txtPageTitle.Text, txtMemo.Text); txtPageTitle.Text = ""; txtMemo.Text = ""; int count = BizPage.GetAllPages().Count; this.aspNetPager.RecordCount = count; this.aspNetPager.CurrentPageIndex = count / 10 + 1; FreshData(this.aspNetPager.CurrentPageIndex - 1); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "myscript", "$('#showBox').html('成功添加一个新页面!');", true); this.ModalPopupExtender2.Show(); }
{ /// <summary> /// 在每个页面加载时判断用户访问该页面的权限 /// </summary> /// <param name="e"></param> protected override void OnPreLoad(EventArgs e) { base.OnPreLoad(e); if (!string.IsNullOrEmpty(User.Identity.Name)) { tb_Mem_Member currentUser = BizMember.GetMemberByID(long.Parse(User.Identity.Name)); tb_Pages currentPage = BizPage.GetPageByTitle(this.Title); if (!BALPermission.ValidateMemberPagePermission(currentUser, currentPage)) { Response.Redirect("~/Common/Aspx/ErrorPage.aspx"); } } else { Response.Redirect("~/Login.aspx"); } }
private void FreshData(int index) { this.aspNetPager.RecordCount = BizPage.GetAllPages().Count; pageGridView.DataSource = BizPage.GetAllPages().Skip(index * 10).Take(10).ToList(); DataBind(); }