protected override void CreateChildControls() { base.CreateChildControls(); try { // few controls with id's sent to target string path = SPUtility.GetGenericSetupPath("TEMPLATE\\IMAGES"); // Group Drop Box SPHtmlSelect dlGroup = new SPHtmlSelect(); dlGroup.ID = this.ID + "dlGroup"; dlGroup.Height = 22; dlGroup.Width = 100; Controls.Add(dlGroup); SPHtmlSelect dlCandidate = new SPHtmlSelect(); dlCandidate.ID = this.ID + "dlCandidate"; dlCandidate.Height = 22; Controls.Add(dlCandidate); // Put the button into the panel UpdatePanel panel = new UpdatePanel() { ID = this.SkinID + "updatePanel", ChildrenAsTriggers = false, UpdateMode = UpdatePanelUpdateMode.Conditional }; Button b = new Button(); b.Text = "Select Image"; b.Click += new EventHandler(Button_OnClick); panel.ContentTemplateContainer.Controls.Add(b); Controls.Add(panel); // Register for async ScriptManager sc = ScriptManager.GetCurrent(Page); if (sc != null) { sc.RegisterAsyncPostBackControl(b); } // Controls.Add(new HtmlGenericControl("br")); HtmlGenericControl lblText = new HtmlGenericControl("span"); lblText.ID = this.ID + "lblText"; lblText.InnerText = "No image selected"; Controls.Add(lblText); list = new GroupedDropDownList(); list.GroupControlId = dlGroup.ID; list.CandidateControlId = dlCandidate.ID; list.DescriptionControlId = lblText.ID; string filter = (Page.IsPostBack && dlGroup.Items.Count > 0) ? dlGroup.Items[dlGroup.SelectedIndex].Value : "*.*"; foreach (string file in Directory.GetFiles(path, filter)) { list.AddItem( Path.GetFileName(file), Path.GetFileNameWithoutExtension(file), file, Path.GetExtension(file).ToLowerInvariant()); } Controls.Add(list); } catch { } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (!Authentication.IsActive()) { Response.Redirect("~/Login.aspx"); return; } User user = Database.GetUser(Authentication.GetEmail()); if (user == null) { Authentication.LogOut(); return; } UserCredits.InnerText = user.Credit.ToString() + " "; if (GroupedDropDownList.Items.Count == 0) { foreach (Category category in Category.GetCategories()) { GroupedDropDownList.AddItemGroup(category.Name); foreach (Subcategory subcategory in category.Subcategories) { GroupedDropDownList.Items.Add(new ListItem(subcategory.Name, category.Id.ToString() + "-" + subcategory.Id.ToString())); } } } if (DurationDropDownList.Items.Count == 0) { DurationDropDownList.Items.Add(new ListItem("30 Days", "30")); DurationDropDownList.Items.Add(new ListItem("14 Days", "14")); DurationDropDownList.Items.Add(new ListItem("7 Days", "7")); DurationDropDownList.Items.Add(new ListItem("3 Days", "3")); DurationDropDownList.Items.Add(new ListItem("1 Day", "1")); } for (int i = 0; i < Constants.ImagesPerListing; i++) { FileUpload fileUpload = new FileUpload(); fileUpload.Attributes["style"] = "display: none"; FileUploads.Controls.Add(fileUpload); } }
protected override void CreateChildControls() { base.CreateChildControls(); try { // few controls with id's sent to target string path = SPUtility.GetGenericSetupPath("TEMPLATE\\IMAGES"); // Group Drop Box SPHtmlSelect dlGroup = new SPHtmlSelect(); dlGroup.ID = this.ID + "dlGroup"; dlGroup.Height = 22; dlGroup.Width = 100; Controls.Add(dlGroup); SPHtmlSelect dlCandidate = new SPHtmlSelect(); dlCandidate.ID = this.ID + "dlCandidate"; dlCandidate.Height = 22; Controls.Add(dlCandidate); Button b = new Button(); b.Text = "Select Image"; Controls.Add(b); Controls.Add(new HtmlGenericControl("br")); HtmlGenericControl lblText = new HtmlGenericControl("span"); lblText.ID = this.ID + "lblText"; lblText.InnerText = "No image selected"; Controls.Add(lblText); list = new GroupedDropDownList(); list.GroupControlId = dlGroup.ID; list.CandidateControlId = dlCandidate.ID; list.DescriptionControlId = lblText.ID; string filter = (Page.IsPostBack && dlGroup.Items.Count > 0) ? dlGroup.Items[dlGroup.SelectedIndex].Value : "*.*"; foreach (string file in Directory.GetFiles(path, filter)) { list.AddItem( Path.GetFileName(file), Path.GetFileNameWithoutExtension(file), file, Path.GetExtension(file).ToLowerInvariant()); } Controls.Add(list); } catch { } }
private void SetListing(Advertisement ad) { if (GroupedDropDownList.Items.Count == 0) { foreach (Category category in Category.GetCategories()) { GroupedDropDownList.AddItemGroup(category.Name); foreach (Subcategory subcategory in category.Subcategories) { GroupedDropDownList.Items.Add(new ListItem(subcategory.Name, category.Id + "-" + subcategory.Id.ToString())); } } } TitleTextBox.Text = ad.Title; GroupedDropDownList.SelectedValue = ad.Category + "-" + ad.Subcategory; DescriptionTextBox.Text = ad.Description; if (ad.IsExpired()) { TitleTextBox.Enabled = false; GroupedDropDownList.Enabled = false; DescriptionTextBox.Enabled = false; EditButtons.Visible = false; ExpirationText.InnerText = "This listing expired on " + ad.GetExpirationDate() + "."; if (ad.Anonymous) { VisiblityText.InnerHtml = "This listing was anonymous."; } else { VisiblityText.InnerHtml = "This listing was not anonymous."; } if (ad.Boosted) { BoostText.InnerHtml = "This listing was boosted."; } else { BoostText.InnerHtml = "This listing was not boosted."; } } else { ExpirationText.InnerText = "This listing expires on " + ad.GetExpirationDate() + "."; if (ad.Anonymous) { VisiblityText.InnerHtml = "This listing is anonymous."; } else { VisiblityText.InnerHtml = "This listing is not anonymous."; } if (ad.Boosted) { BoostText.InnerHtml = "This listing is boosted."; } else { BoostText.InnerHtml = "This listing is not boosted."; } } if (ad.Anonymous) { Visibility.Attributes["class"] = "option-container invisible"; Spy.Attributes["class"] = "spy white"; } else { Visibility.Attributes["class"] = "option-container visible"; Spy.Attributes["class"] = "spy black"; } if (ad.Boosted) { Boost.Attributes["class"] = "option-container enabled"; Star.Attributes["class"] = "star enabled-star"; } else { Boost.Attributes["class"] = "option-container disabled"; Star.Attributes["class"] = "star disabled-star"; } }