您目前尚未登陆,请选择【登陆】或【注册
首页->留言本类->51aspx修正版简单三层留言板源码>>LMControl/AdministratorControl.ascx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:51aspx修正版简单三层留言板源码
当前文件:文件类型 LeaveMessageMVC/LMControl/AdministratorControl.ascx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11 12using LeaveMessageMVC.MVC.BusinessLogicLayer.ParameterInformation; 13using LeaveMessageMVC.MVC.DataBaseControlLayer; 14using LeaveMessageMVC.MVC.BusinessLogicLayer; 15using LeaveMessageMVC.MVC.BusinessLogicLayer.SomeFunctions; 16 17//该源码下载自www.51aspx.com(51aspx.com) 18 19public partial class AdministratorControl : System.Web.UI.UserControl 20{ 21 LeaveMessageMVC.MVC.BusinessLogicLayer.ParameterInformation.LeaveMessagePara LMP = new LeaveMessagePara(); 22 23 protected void Page_Load(object sender, EventArgs e) 24 { 25 if (!Page.IsPostBack) 26 { 27 LMBind(0); 28 DeleteSNButton.Attributes.Add("onclick", "return confirm(\"确定要删除所选留言吗?\")"); 29 //如果是false,不会激活服务器端的事件 30 } 31 } 32 33 ... 80 81 protected string ShortString(string txt, int wordSize, string id) 82 { 83 //限制显示的字符数,避免篇幅太大 84 if (txt == "" && id == "") 85 txt = "无标题"; 86 else 87 { 88 txt = txt.Replace("<", "&lt;"); 89 txt = txt.Replace(">", "&gt;"); 90 } 91 92 if (id == "") 93 { 94 if (txt.Length > wordSize && wordSize != 0) 95 return txt.Substring(0, wordSize - 3) + "..."; 96 else 97 return txt; 98 } 99 else 100 { 101 if (txt.Length > wordSize && wordSize != 0) 102 return "<a href=\"ShowDetail.aspx?d_ID=" + id + "\" target=\"_blank\">" + txt.Substring(0, wordSize - 3) + "...</a>"; 103 else 104 return "<a href=\"ShowDetail.aspx?d_ID=" + id + "\" target=\"_blank\">" + txt + "</a>"; 105 } 106 107 } 108 109 ////调用这个函数也可以实现全选CheckBox,但会出现闪屏现象,因为是传会服务器 110 //protected void WillBeDeleted_Checked() 111 //{ 112 // foreach (RepeaterItem item in LMListRepeater.Items) 113 // { 114 // CheckBox cb = (CheckBox)item.FindControl("WillBeDeleted"); //"WillBeDeleted"为CheckBox控件ID 115 // cb.Checked = true; 116 // } 117 //} 118 119 protected void DeleteSNButton_Click(object sender, EventArgs e) 120 { 121 string[] DID = new string[50]; 122 int SelectedLines = 0; 123 124 foreach (DataGridItem item in LMListDG.Items) 125 { 126 CheckBox cb = (CheckBox)item.FindControl("WillBeDeleted"); //"WillBeDeleted"为CheckBox控件ID 127 if (cb.Checked == true) 128 { 129 DID[SelectedLines++] = LMListDG.DataKeys[item.ItemIndex].ToString(); 130 } 131 } 132 133 if (LMManage.DeleteLeaveMessage(DID)) 134 { 135 //每次从数据库删除留言成功,就使保存 表行数 的全局变量 -n(n为被删除留言行数) 136 Application.Lock(); 137 Application["TableCount"] = (int)Application["TableCount"] - SelectedLines; 138 Application.UnLock(); 139 140 LMBind(0); 141 } 142 } 143 144 protected void LMListDG_PageIndexChanged(object source, DataGridPageChangedEventArgs e) 145 { 146 LMListDG.CurrentPageIndex = e.NewPageIndex; 147 LMBind(0); 148 } 149 150 protected void LMListDG_EditCommand(object source, DataGridCommandEventArgs e) 151 { 152 LMListDG.EditItemIndex = e.Item.ItemIndex; 153 LMBind(0); 154 } 155 156 protected void LMListDG_UpdateCommand(object source, DataGridCommandEventArgs e) 157 { 158 LMP.ID = LMListDG.DataKeys[e.Item.ItemIndex].ToString(); 159 LMP.Title = ((TextBox)e.Item.FindControl("TB_Title")).Text; 160 LMP.Contents = ((TextBox)e.Item.FindControl("TB_Contents")).Text; 161 LMP.WriteBack = ((TextBox)e.Item.FindControl("TB_WriteBack")).Text; 162 163 if (LMManage.UpdateLeaveMessageAll(LMP)) 164 { 165 Response.Write("<Script Language=JavaScript>alert(\"更新成功!\");</script>"); 166 } 167 else Response.Redirect("ShowErrorMsg.aspx?name=Administrator"); 168 169 LMListDG.EditItemIndex = -1; 170 171 LMBind(0); 172 } 173 174 protected void LMListDG_CancelCommand(object source, DataGridCommandEventArgs e) 175 { 176 LMListDG.EditItemIndex = -1; 177 LMBind(0); 178 } 179} 180
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:51aspx修正版简单三层留言板源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号