📄 categories.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Zeroone.FileSystem;
public partial class Admin_Poll_Categories : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
rptPollCategories.DataSource = CategoryController.GetChildCategories("/zeroone-polls/");
this.rptPollCategories.DataBind();
}
}
protected void rptPollCategories_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "edit")
{
e.Item.FindControl("ltlName").Visible = false;
e.Item.FindControl("tbName").Visible = true;
e.Item.FindControl("revName").Visible = true;
e.Item.FindControl("rfvName").Visible = true;
e.Item.FindControl("lbtnEdit").Visible = false;
e.Item.FindControl("lbtnUpdate").Visible = true;
e.Item.FindControl("lbtnCancel").Visible = true;
}
else if (e.CommandName == "update")
{
Category c = CategoryController.GetCategory((string)e.CommandArgument);
c.Path = Path.GetParentPath(c.Path) + ((TextBox)e.Item.FindControl("tbName")).Text;
c.Name = ((TextBox)e.Item.FindControl("tbName")).Text;
c.Update();
Response.Redirect("Categories.aspx");
}
else
{
Response.Redirect("Categories.aspx");
}
}
protected void lbtnDelete_Click(object sender, EventArgs e)
{
foreach (RepeaterItem item in this.rptPollCategories.Items)
{
if ((item.ItemType == ListItemType.AlternatingItem) || (item.ItemType == ListItemType.Item))
{
System.Web.UI.HtmlControls.HtmlInputCheckBox htmlCB = (HtmlInputCheckBox)item.FindControl("categoryCheck");
if (htmlCB.Checked)
{
string path = htmlCB.Value;
CategoryController.Delete(path);
}
}
}
Response.Redirect("Categories.aspx");
}
protected void btnManageCategory_Click(object sender, EventArgs e)
{
Category c = new Category();
c.Name = tbNewCategoryName.Text;
c.Path = "/zeroone-polls/" + tbNewCategoryName.Text;
c.Create();
Response.Redirect("Categories.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -