protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { string guid = Guid.NewGuid().ToString(); UploadSession obj = (UploadSession)Session["upload"]; string filename = Server.MapPath("/Albums/" + obj.Folder + "/" + guid + ".JPG"); AjaxFileUpload1.SaveAs(filename); SqlParameter pID = new SqlParameter("AlbumID", SqlDbType.Int); pID.Value = obj.Id; SqlParameter pUrl = new SqlParameter("ImageUrl", SqlDbType.NVarChar); pUrl.Value = guid + ".jpg"; SqlParameter insertedKey = new SqlParameter("AlbumDetailID", SqlDbType.Int); insertedKey.Direction = ParameterDirection.Output; string NewsID = DataAccessLayer.ExcuteNoneQueryHasOutput("Album_InsertAlbumDetail", "AlbumDetailID", pID, pUrl, insertedKey); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (!AjaxFileUpload1.IsInFileUploadPostBack) { GetCategory(); string id = Request.QueryString["id"].ToString(); string folder = ""; string title = ""; string cate = ""; bool hot = false; SqlParameter pID = new SqlParameter("AlbumID", SqlDbType.Int); pID.Value = id; DataSet ds = DataAccessLayer.ExecuteDataSet("Album_LoadAlbumByID", pID); if (ds != null && ds.Tables != null && ds.Tables[0].Rows.Count > 0) { folder = ds.Tables[0].Rows[0]["FolderPath"].ToString(); title = ds.Tables[0].Rows[0]["AlbumTitle"].ToString(); cate = ds.Tables[0].Rows[0]["NewsCateID"] != null?ds.Tables[0].Rows[0]["NewsCateID"].ToString():""; hot = bool.Parse(ds.Tables[0].Rows[0]["HotAlbum"].ToString() == "" ? "False" : ds.Tables[0].Rows[0]["HotAlbum"].ToString()); ListItem selectedListItem = DropDownList1.Items.FindByValue(cate); if (selectedListItem != null) { selectedListItem.Selected = true; } } UploadSession up = new UploadSession(); up.Id = id; up.Folder = folder; Session["upload"] = up; TextBox1.Text = title; chkHot.Checked = hot; } }
protected void Page_Load(object sender, EventArgs e) { if(IsPostBack) return; if (!AjaxFileUpload1.IsInFileUploadPostBack) { GetCategory(); string id = Request.QueryString["id"].ToString(); string folder = ""; string title = ""; string cate = ""; bool hot = false; SqlParameter pID = new SqlParameter("AlbumID", SqlDbType.Int); pID.Value = id; DataSet ds = DataAccessLayer.ExecuteDataSet("Album_LoadAlbumByID", pID); if (ds != null && ds.Tables != null && ds.Tables[0].Rows.Count > 0) { folder = ds.Tables[0].Rows[0]["FolderPath"].ToString(); title = ds.Tables[0].Rows[0]["AlbumTitle"].ToString(); cate =ds.Tables[0].Rows[0]["NewsCateID"]!=null?ds.Tables[0].Rows[0]["NewsCateID"].ToString():""; hot = bool.Parse(ds.Tables[0].Rows[0]["HotAlbum"].ToString() == "" ? "False" : ds.Tables[0].Rows[0]["HotAlbum"].ToString()); ListItem selectedListItem = DropDownList1.Items.FindByValue(cate); if (selectedListItem != null) { selectedListItem.Selected = true; } } UploadSession up = new UploadSession(); up.Id = id; up.Folder = folder; Session["upload"] = up; TextBox1.Text = title; chkHot.Checked = hot; } }