TechEthical CEHP
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
namespace Bathuasoft.admin
{
public partial class AddGallery_Culture_And_Events : System.Web.UI.Page
{
string ImagePath = "~/img/Gallery/Culture-And-Events/";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["Loginxtr"].ToString() != "1254lkjhhfdgftfrdgf")
{
Response.Redirect("login.aspx");
}
BindGrid();
}
}
protected void btnUpload_Click(object sender, EventArgs e)
{
if (fileuploadimages.HasFile == false)
{
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", "<script>alert('No File Uploaded.')</script>", false);
}
else
{
foreach (var file in fileuploadimages.PostedFiles)
{
string filename = Path.GetFileName(fileuploadimages.PostedFile.FileName);
file.SaveAs(Server.MapPath(ImagePath + file.FileName));
}
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", "<script>alert('All Files Uploaded Successfully.')</script>", false);
}
BindGrid();
}
protected void Delete(object sender, EventArgs e)
{
foreach (GridViewRow row in gvFiles.Rows)
{
if ((row.FindControl("cbImage") as CheckBox).Checked)
{
string imagePath = (row.FindControl("imgImage") as Image).AlternateText;
if (File.Exists(Server.MapPath(imagePath)))
{
File.Delete(Server.MapPath(imagePath));
}
}
}
BindGrid();
}
private void BindGrid()
{
gvFiles.DataSource = null;
string[] filePaths = System.IO.Directory.GetFiles(Server.MapPath(ImagePath));
List<ListItem> files = new List<ListItem>();
foreach (string filePath in filePaths)
{
string fileName = Path.GetFileName(filePath);
files.Add(new ListItem(fileName, ImagePath + fileName));
}
gvFiles.DataSource = files;
gvFiles.DataBind();
}
}
}
TechEthical Mini WebShell Version 1.0, Coded By The_M@T3