protected void ButtonAdd_OnClick(object sender, EventArgs e) { if (Page.IsValid) { Guid parentID = new Guid(DropDownListDirectories.SelectedValue); Guid templateID = new Guid(DropDownListTemplates.SelectedValue); string filePath = Path.GetTempFileName(); InputFileUpload.PostedFile.SaveAs(filePath); try { DataTable data = getDataFromXLS(filePath); int count = 0; foreach (DataRow dr in data.Rows) { string filename = Clean(dr["Filename"]); if (filename != null && filename.Length > 0) { CmsPage page = new CmsPage(); page.FileName = filename; page.Title = Clean(dr["Title"]); page.ParentID = parentID; page.TemplateID = templateID; page.Insert(); count++; AddAttribute(page, "website", Clean(dr["Website"])); AddAttribute(page, "phone", Clean(dr["Phone"])); AddAttribute(page, "street", Clean(dr["Street"])); AddAttribute(page, "addressHint", Clean(dr["AddressHint"])); AddAttribute(page, "city", Clean(dr["City"])); AddAttribute(page, "subcategory", Clean(dr["Subcategory"])); //string description = Clean(dr["Description"]); //if (description != null && description.Length > 0) { // LiteralContent content = (LiteralContent)page.ContentBlocks["Body"]; // content.Text = description; // page //} //Website Phone Street AddressHint Subcategory City Featured City State Description } } MessageBox1.ShowMessage(MessageBox.MessageBoxMode.Info, count + " pages have been created."); } finally { try { File.Delete(filePath); } catch (Exception ex) { } } } }
protected void ButtonAddPage_OnClick(object sender, EventArgs e) { if(Page.IsValid){ CmsPage p = new CmsPage(); DataBindingManagerPage.DataSource = p; DataBindingManagerPage.PullData(); p.ParentID = DirectoryID; if(p.TemplateID == Guid.Empty){ p.IsStatic = true; } CmsWebDirectory d = CmsWebDirectory.FindByID(DirectoryID); p.SortOrder = d.Files.Count; //TODO: Pull this out into page! p.Insert(); Response.Redirect(p.FileType.EditUrl + "?FileID=" + p.ID); } }