在页面AddFolder.aspx上添加一个DropdownList控件,一个TextBox控件,一个非空验证控件,两个Button按钮。
protected void Page_Load(object sender,EventArgs e)
{//显示目录列表的信息
if(!Page.IsPostBack){BindDirectoryData();}
}
private void BindDirectoryData()
{//显示目录列表信息
Disk disk=new Disk();
disk.ShowDirectory(DirList,-1);
}
protected void AddBtn_Click(object sender,EventArgs e)
{
try
{//定义对象
IDisk disk=new Disk();
disk.AddDirectory(Name.Text.Trim(),Int32.Parse(DirList.SelectedValue));
Response.Write("<script>alert('"+"添加数据成功,请妥善保管好你的数据!"+"');</script>");
}
catch(Exception ex)
{//跳转到异常错误处理页面
Response.Redirect("ErrorPage.aspx?ErrorMsg="+ex.Message.Replace("<br>","").Replace("/n","")+"&ErrorUrl="+Request.Url.ToString().Replace("<br>","").Replace("/n",""));
}
}
protected void ReturnBtn_Click(object sender,EventArgs e)
{Response.Redirect("~/ShowDisk.aspx");}
protected void Page_Load(object sender,EventArgs e)
{//显示目录列表的信息
if(!Page.IsPostBack){BindDirectoryData();}
}
private void BindDirectoryData()
{//显示目录列表信息
Disk disk=new Disk();
disk.ShowDirectory(DirList,-1);
}
protected void AddBtn_Click(object sender,EventArgs e)
{
try
{//定义对象
IDisk disk=new Disk();
disk.AddDirectory(Name.Text.Trim(),Int32.Parse(DirList.SelectedValue));
Response.Write("<script>alert('"+"添加数据成功,请妥善保管好你的数据!"+"');</script>");
}
catch(Exception ex)
{//跳转到异常错误处理页面
Response.Redirect("ErrorPage.aspx?ErrorMsg="+ex.Message.Replace("<br>","").Replace("/n","")+"&ErrorUrl="+Request.Url.ToString().Replace("<br>","").Replace("/n",""));
}
}
protected void ReturnBtn_Click(object sender,EventArgs e)
{Response.Redirect("~/ShowDisk.aspx");}