public void CreateBody(HtmlGenericControl parent) { HtmlGenericControl body = new HtmlGenericControl("div"); body.Attributes.Add("class", "modal-body"); if (BodyTemplate != null) { BodyTemplate.InstantiateIn(body); } parent.Controls.Add(body); }
protected override void CreateChildControls() { base.CreateChildControls(); // header if (HeaderTemplate != null) { _headerTemplate = new HtmlGenericControl("header"); _headerTemplate.Attributes.Add("class", "modal-header"); HtmlGenericControl h2 = new HtmlGenericControl("h2"); h2.Attributes.Add("class", "modal-title"); _headerTemplate.Controls.Add(h2); this.Controls.Add(_headerTemplate); HeaderTemplate.InstantiateIn(h2); } // body with empty content by default _bodyTemplate = new HtmlGenericControl("div"); _bodyTemplate.Attributes.Add("class", "modal-body"); this.Controls.Add(_bodyTemplate); if (BodyTemplate != null) { BodyTemplate.InstantiateIn(_bodyTemplate); } // footer if (FooterTemplate != null) { _footerTemplate = new HtmlGenericControl("div"); _footerTemplate.Attributes.Add("class", "modal-footer"); this.Controls.Add(_footerTemplate); FooterTemplate.InstantiateIn(_footerTemplate); } try { Control target = Page.FindControlRecursive(this.AssociateControlID); if (target is WebControl wc) { wc.Attributes["href"] = "#" + this.ClientID; wc.AddCssClass(IsClosable ? "wb-lbx" : "wb-lbx lbx-modal"); } } catch (Exception) { throw new Exception("AssociateControlID property for WetModal with ID " + this.ID + " should refer to an html control with the href attribute."); } }
// ********************************************************************* // DataBindThread // /// <summary> /// Performs the DataBinding for each thread item bound to the repeater. /// </summary> /// // ********************************************************************/ private void DataBindThread(Object sender, EventArgs e) { Table table; TableRow tr; TableCell td; RepeaterItem container; Post post; bool isBelowThreshHold = false; bool isFirstPost = false; // Get the table instance we databound table = (Table)sender; // Get the data item to be bound to container = (RepeaterItem)table.NamingContainer; // Extract the original databound class type post = (Post)container.DataItem; // If we're the first item, set the threadedStartPostLevel. // This private member variable determines what nesting level // to start at. if (container.ItemIndex == 0) { threadedStartPostLevel = post.PostLevel; isFirstPost = true; } // Determine if we are below the threshold of threads to display // with body. if ((post.PostLevel - threadedStartPostLevel) > Threshhold) { isBelowThreshHold = true; } // This whitespace is used to separate thread items if ((!isBelowThreshHold) && (!isFirstPost)) { // Add some white space tr = new TableRow(); td = new TableCell(); td.ColumnSpan = 2; td.Height = Unit.Pixel(12); tr.Controls.Add(td); table.Controls.Add(tr); } // Prepare to display the thread tr = new TableRow(); // If we're not the first post, indent if (!isFirstPost) { // Indenting td = new TableCell(); td.Wrap = false; td.VerticalAlign = VerticalAlign.Top; Label indent = new Label(); indent.CssClass = "normalTextSmallBold"; indent.DataBinding += new System.EventHandler(HandleIndentingForThreaded); td.Controls.Add(indent); tr.Controls.Add(td); } // Databind this cell for the actual thread display td = new TableCell(); td.DataBinding += new System.EventHandler(HandleDataBindingForThreadTitle); if (isFirstPost) { td.ColumnSpan = 2; } else { td.Width = Unit.Percentage(100); } tr.Controls.Add(td); table.Controls.Add(tr); // Display body of post if (!isBelowThreshHold) { td = new TableCell(); tr = new TableRow(); // Set some properties on the row td.CssClass = "forumRow"; // If we're not the first item, let's add a bit of whitespace if (isFirstPost) { td.ColumnSpan = 2; } else { tr.Controls.Add(new TableCell()); } // Template? if (null != this.BodyTemplate) { BodyTemplate.InstantiateIn(td); tr.Controls.Add(td); table.Controls.Add(tr); return; } Label body = new Label(); // Set up the body text body.CssClass = "normalTextSmall"; body.Text = Globals.FormatPostBody(post.Body); postUser = Users.GetUserInfo(post.Username, false); if (postUser.Signature != "") { body.Text += Globals.FormatSignature(postUser.Signature); } // Add the body to the cell td.Controls.Add(body); tr.Controls.Add(td); table.Controls.Add(tr); } }