public static MvcHtmlString RenderContent(HtmlHelper helper, TypeContext typeContext, RenderContentMode mode, EntityBase line) { TypeContext tc = TypeContextUtilities.CleanTypeContext((TypeContext)typeContext); ViewDataDictionary vdd = GetViewData(helper, line, tc); string partialViewName = line.PartialViewName ?? OnPartialViewName(tc); switch (mode) { case RenderContentMode.Content: return(helper.Partial(partialViewName, vdd)); case RenderContentMode.ContentInVisibleDiv: return(helper.Div(typeContext.Compose(EntityBaseKeys.Entity), helper.Partial(partialViewName, vdd), "", null)); case RenderContentMode.ContentInInvisibleDiv: return(helper.Div(typeContext.Compose(EntityBaseKeys.Entity), helper.Partial(partialViewName, vdd), "", new Dictionary <string, object> { { "style", "display:none" } })); default: throw new InvalidOperationException(); } }
public static MvcHtmlString RenderPopup(HtmlHelper helper, TypeContext typeContext, RenderPopupMode mode, EntityBase line, bool isTemplate = false) { TypeContext tc = TypeContextUtilities.CleanTypeContext((TypeContext)typeContext); ViewDataDictionary vdd = GetViewData(helper, line, tc); string partialViewName = line.PartialViewName ?? OnPartialViewName(tc); vdd[ViewDataKeys.PartialViewName] = partialViewName; vdd[ViewDataKeys.ViewMode] = !line.ReadOnly; vdd[ViewDataKeys.ViewMode] = ViewMode.View; vdd[ViewDataKeys.ShowOperations] = true; vdd[ViewDataKeys.SaveProtected] = OperationLogic.IsSaveProtected(tc.UntypedValue.GetType()); vdd[ViewDataKeys.WriteEntityState] = !isTemplate && !(tc.UntypedValue is EmbeddedEntity) && ((ModifiableEntity)tc.UntypedValue).Modified == ModifiedState.SelfModified; switch (mode) { case RenderPopupMode.Popup: return helper.Partial(Navigator.Manager.PopupControlView, vdd); case RenderPopupMode.PopupInDiv: return helper.Div(typeContext.Compose(EntityBaseKeys.Entity), helper.Partial(Navigator.Manager.PopupControlView, vdd), "", new Dictionary<string, object> { { "style", "display:none" } }); default: throw new InvalidOperationException(); } }
public static MvcHtmlString RenderPopup(HtmlHelper helper, TypeContext typeContext, RenderPopupMode mode, EntityBase line, bool isTemplate = false) { TypeContext tc = TypeContextUtilities.CleanTypeContext((TypeContext)typeContext); ViewDataDictionary vdd = GetViewData(helper, line, tc); string partialViewName = line.PartialViewName ?? OnPartialViewName(tc); vdd[ViewDataKeys.PartialViewName] = partialViewName; vdd[ViewDataKeys.ViewMode] = !line.ReadOnly; vdd[ViewDataKeys.ViewMode] = ViewMode.View; vdd[ViewDataKeys.ShowOperations] = true; vdd[ViewDataKeys.RequiresSaveOperation] = EntityKindCache.RequiresSaveOperation(tc.UntypedValue.GetType()); vdd[ViewDataKeys.WriteEntityState] = !isTemplate && !(tc.UntypedValue is EmbeddedEntity) && ((ModifiableEntity)tc.UntypedValue).Modified == ModifiedState.SelfModified; switch (mode) { case RenderPopupMode.Popup: return(helper.Partial(Navigator.Manager.PopupControlView, vdd)); case RenderPopupMode.PopupInDiv: return(helper.Div(typeContext.Compose(EntityBaseKeys.Entity), helper.Partial(Navigator.Manager.PopupControlView, vdd), "", new Dictionary <string, object> { { "style", "display:none" } })); default: throw new InvalidOperationException(); } }
private static MvcHtmlString InternalListDetailElement <T>(this HtmlHelper helper, HtmlStringBuilder sbOptions, TypeElementContext <T> itemTC, EntityListDetail listDetail) { HtmlStringBuilder sb = new HtmlStringBuilder(); sb.AddLine(EntityBaseHelper.WriteIndex(helper, itemTC)); sb.AddLine(helper.HiddenRuntimeInfo(itemTC)); if (EntityBaseHelper.EmbeddedOrNew((Modifiable)(object)itemTC.Value)) { sb.AddLine(EntityBaseHelper.RenderContent(helper, itemTC, RenderContentMode.ContentInInvisibleDiv, listDetail)); } else if (itemTC.Value != null) { sb.Add(helper.Div(itemTC.Compose(EntityBaseKeys.Entity), null, "", new Dictionary <string, object> { { "style", "display:none" } })); } sbOptions.Add(new HtmlTag("option") .Id(itemTC.Compose(EntityBaseKeys.ToStr)) .Class("sf-entity-list-option") .Let(a => itemTC.Index > 0 ? a : a.Attr("selected", "selected")) .SetInnerText(itemTC.Value?.ToString()) .ToHtml(TagRenderMode.Normal)); return(sb.ToHtml()); }
public static MvcHtmlString RenderContent(HtmlHelper helper, TypeContext typeContext, RenderContentMode mode, EntityBase line) { TypeContext tc = TypeContextUtilities.CleanTypeContext((TypeContext)typeContext); ViewDataDictionary vdd = GetViewData(helper, line, tc); string partialViewName = line.PartialViewName ?? OnPartialViewName(tc); switch (mode) { case RenderContentMode.Content: return helper.Partial(partialViewName, vdd); case RenderContentMode.ContentInVisibleDiv: return helper.Div(typeContext.Compose(EntityBaseKeys.Entity), helper.Partial(partialViewName, vdd), "", null); case RenderContentMode.ContentInInvisibleDiv: return helper.Div(typeContext.Compose(EntityBaseKeys.Entity), helper.Partial(partialViewName, vdd), "", new Dictionary<string, object> { { "style", "display:none" } }); default: throw new InvalidOperationException(); } }
protected void btnSaveEmployee_Click(object sender, EventArgs e) { string errorMessage = validate(); if (errorMessage.Length == 0) { _employee.FirstName = txtFirstName.Text.Trim().Length > 0 ? txtFirstName.Text.Trim() : null; _employee.MiddleName = txtMiddleName.Text.Trim().Length > 0 ? txtMiddleName.Text.Trim() : null; _employee.LastName = txtLastName.Text.Trim().Length > 0 ? txtLastName.Text.Trim() : null; _employee.Ssn = txtSSN.Text.Trim().Length > 0 ? txtSSN.Text.Trim().GetNumbers() : null; _employee.EmployeeNo = txtEmployeeNo.Text.Trim().Length > 0 ? txtEmployeeNo.Text.Trim() : null; _employee.Address1 = txtAddress1.Text.Trim().Length > 0 ? txtAddress1.Text.Trim() : null; _employee.Address2 = txtAddress2.Text.Trim().Length > 0 ? txtAddress2.Text.Trim() : null; _employee.City = txtCity.Text.Trim().Length > 0 ? txtCity.Text.Trim() : null; _employee.State = ddlState.SelectedValue.Length > 0 ? ddlState.SelectedValue : null;; _employee.ZipCode = txtZip.Text.Trim().Length > 0 ? txtZip.Text.Trim() : null; _employee.Phone = txtPhone.Text.Trim().GetNumbers().Length > 0 ? txtPhone.Text.Trim().GetNumbers() : null; _employee.IsActive = true; _employee.IsEnabled = true; if (txtUsername.Text.Trim().Length > 0) { _employee.Username = txtUsername.Text.Trim().ToLower(); } else { _employee.Username = null; } if (txtPassword.Visible && txtPassword.Text.Trim().Length > 0) { _employee.Password = Hashing.ComputeHash(txtPassword.Text.Trim(), HashType.MD5); } else if (txtNewPassword.Visible) { if (txtNewPassword.Text.Trim().Length > 0) { _employee.Password = Hashing.ComputeHash(txtNewPassword.Text.Trim(), HashType.MD5); } else { _employee.Password = null; } } else { _employee.Password = null; } _employee.Save(); Response.Redirect("~/Employees.aspx"); } else { messages.Controls.Add(HtmlHelper.Div("error", errorMessage)); } }
static MvcHtmlString InternalListElement <T>(this HtmlHelper helper, HtmlStringBuilder sbOptions, TypeElementContext <T> itemTC, EntityList entityList) { HtmlStringBuilder sb = new HtmlStringBuilder(); sb.AddLine(EntityBaseHelper.WriteIndex(helper, itemTC)); sb.AddLine(helper.HiddenRuntimeInfo(itemTC)); if (entityList.IsVisible == null || entityList.IsVisible(itemTC)) { if (EntityBaseHelper.EmbeddedOrNew((Modifiable)(object)itemTC.Value)) { sb.AddLine(EntityBaseHelper.RenderPopup(helper, itemTC, RenderPopupMode.PopupInDiv, entityList)); } else if (itemTC.Value != null) { sb.Add(helper.Div(itemTC.Compose(EntityBaseKeys.Entity), null, "", new Dictionary <string, object> { { "style", "display:none" }, { "class", "sf-entity-list" } })); } var optionTag = new HtmlTag("option") .Id(itemTC.Compose(EntityBaseKeys.ToStr)) .Class("sf-entity-list-option") .Let(a => itemTC.Index > 0 ? a : a.Attr("selected", "selected")) .SetInnerText(itemTC.Value?.ToString()); if (!EntityBaseHelper.EmbeddedOrNew((Modifiable)(object)itemTC.Value)) { PrimaryKey?idOrNull = null; Type type = itemTC.Value.GetType(); if (type.IsLite()) { idOrNull = ((Lite <IEntity>)itemTC.Value).IdOrNull; } if (type.IsEntity()) { idOrNull = ((Entity)(object)itemTC.Value).IdOrNull; } optionTag.Attr("title", " ".CombineIfNotEmpty(itemTC.Value.GetType().CleanType().NiceName(), idOrNull)); } sbOptions.Add(optionTag.ToHtml(TagRenderMode.Normal)); } return(sb.ToHtml()); }
protected void btnSaveUser_Click(object sender, EventArgs e) { string errorMessage = validate(); if (errorMessage.Length == 0) { _user.FirstName = txtFirstName.Text.Trim().Length > 0 ? txtFirstName.Text.Trim() : null; _user.MiddleName = txtMiddleName.Text.Trim().Length > 0 ? txtMiddleName.Text.Trim() : null; _user.LastName = txtLastName.Text.Trim().Length > 0 ? txtLastName.Text.Trim() : null; _user.EmailAddress = txtEmailAddress.Text.Trim().Length > 0 ? txtEmailAddress.Text.Trim() : null; _user.UserTypeId = Convert.ToInt32(ddlUserType.SelectedValue); _user.IsActive = true; _user.IsEnabled = true; _user.Username = txtUsername.Text.Trim().ToLower(); if (txtPassword.Visible) { _user.Password = Hashing.ComputeHash(txtPassword.Text.Trim(), HashType.MD5); } else { _user.Password = Hashing.ComputeHash(txtNewPassword.Text.Trim(), HashType.MD5); } _user.Save(); foreach (DataListItem dli in dtListAsset.Items) { saveUserAccount(dli); } foreach (DataListItem dli in dtListOilFiltration.Items) { saveUserAccount(dli); } foreach (DataListItem dli in dtListRecycle.Items) { saveUserAccount(dli); } Response.Redirect("Users.aspx"); } else { messages.Controls.Add(HtmlHelper.Div("error", errorMessage)); } }
protected void btnSaveSettingss_Click(object sender, EventArgs e) { if (txtBaleWeight.Text.Trim().Length == 0 || txtNumberOfBagsInBale.Text.Trim().Length == 0) { errormessages.Controls.Add(HtmlHelper.Div("You must enter values.")); errormessages.Visible = true; return; } baleWeightSetting.DecimalValue = Convert.ToDecimal(txtBaleWeight.Text.Trim()); baleWeightSetting.IsDirty = true; baleWeightSetting.Save(); numberOfBagsInBale.IntValue = Convert.ToInt32(txtNumberOfBagsInBale.Text.Trim()); numberOfBagsInBale.IsDirty = true; numberOfBagsInBale.Save(); Response.Redirect("Home.aspx"); }
protected void btnSaveAccount_Click(object sender, EventArgs e) { string errorMessage = validate(); if (errorMessage.Length == 0) { _account.Name = txtAcctName.Text.Trim(); _account.AccountNo = txtAcctNo.Text.Trim().Length > 0 ? txtAcctNo.Text.Trim() : null; _account.Address1 = txtAddress1.Text.Trim().Length > 0 ? txtAddress1.Text.Trim() : null; _account.Address2 = txtAddress2.Text.Trim().Length > 0 ? txtAddress2.Text.Trim() : null; _account.City = txtCity.Text.Trim().Length > 0 ? txtCity.Text.Trim() : null; _account.State = ddlState.SelectedValue.Length > 0 ? ddlState.SelectedValue : null;; _account.ZipCode = txtZip.Text.Trim().Length > 0 ? txtZip.Text.Trim() : null; _account.Phone = txtPhone.Text.Trim().GetNumbers().Length > 0 ? txtPhone.Text.Trim().GetNumbers() : null; _account.IsActive = true; _account.MainContact = txtMainContact.Text.Trim().Length > 0 ? txtMainContact.Text.Trim() : null; _account.Notes = txtNotes.Text.Trim().Length > 0 ? txtNotes.Text.Trim() : null; if (_account.IsNew) { _serviceLocation = new ServiceLocationEntity(); _serviceLocation.Account = _account; } _serviceLocation.Name = _account.Name; _serviceLocation.Address1 = _account.Address1; _serviceLocation.Address2 = _account.Address2; _serviceLocation.City = _account.City; _serviceLocation.ZipCode = _account.ZipCode; _serviceLocation.MainContact = _account.MainContact; _serviceLocation.Notes = _account.Notes; _serviceLocation.Phone = _account.Phone; _serviceLocation.ServiceTypeId = (int)ServiceTypeEntity.ServiceTypes.RecycleOnly; _account.Save(); _serviceLocation.Save(); Response.Redirect("~/EditRecyclingAccount.aspx?acctId=" + _account.AccountId.ToString()); } else { messages.Controls.Add(HtmlHelper.Div("error", errorMessage)); } }
protected void btnSaveServiceLocation_Click(object sender, EventArgs e) { string errorMessage = validate(); if (errorMessage.Length == 0) { _serviceLocation.Name = txtServiceLocationName.Text.Trim(); _serviceLocation.Address1 = txtAddress1.Text.Trim().Length > 0 ? txtAddress1.Text.Trim() : null; _serviceLocation.Address2 = txtAddress2.Text.Trim().Length > 0 ? txtAddress2.Text.Trim() : null; _serviceLocation.City = txtCity.Text.Trim().Length > 0 ? txtCity.Text.Trim() : null; _serviceLocation.State = ddlState.SelectedValue.Length > 0 ? ddlState.SelectedValue.Trim() : null; _serviceLocation.ZipCode = txtZip.Text.Trim().Length > 0 ? txtZip.Text.Trim() : null; _serviceLocation.Phone = txtPhone.Text.Trim().GetNumbers().Length > 0 ? txtPhone.Text.Trim().GetNumbers() : null; _serviceLocation.MainContact = txtMainContact.Text.Trim().Length > 0 ? txtMainContact.Text.Trim() : null; _serviceLocation.Notes = txtNotes.Text.Trim().Length > 0 ? txtNotes.Text.Trim() : null; _serviceLocation.Save(); Response.Redirect("~/EditServiceLocation.aspx?id=" + _serviceLocation.ServiceLocationId.ToString()); } else { messages.Controls.Add(HtmlHelper.Div("error", errorMessage)); } }
public static MvcHtmlString Div(this HtmlHelper html, string id, MvcHtmlString innerHTML, string cssClass) { return(html.Div(id, innerHTML, cssClass, null)); }
internal static MvcHtmlString InternalFileLine(this HtmlHelper helper, FileLine fileLine) { if (!fileLine.Visible) { return(MvcHtmlString.Empty); } IFile value = fileLine.GetFileValue(); HtmlStringBuilder sbg = new HtmlStringBuilder(); using (sbg.SurroundLine(new HtmlTag("div").Id(fileLine.Prefix).Class("sf-field SF-control-container"))) { sbg.AddLine(new HtmlTag("link").Attrs(new { rel = "stylesheet", type = "text/css", href = RouteHelper.New().Content("~/Files/Content/Files.css") }).ToHtmlSelf()); if (value != null) { sbg.AddLine(helper.Div(fileLine.Compose(EntityBaseKeys.Entity), null, "", new Dictionary <string, object> { { "style", "display:none" } })); } fileLine.ValueHtmlProps.AddCssClass("form-control"); bool hasEntity = value != null && value.FileName.HasText(); using (sbg.SurroundLine(new HtmlTag("div", fileLine.Compose("DivOld")).Attr("style", "display:" + (hasEntity ? "block" : "none")))) { HtmlStringBuilder sb = new HtmlStringBuilder(); using (sb.SurroundLine(new HtmlTag("div", fileLine.Compose("inputGroup")).Class("input-group"))) { if (fileLine.Download != DownloadBehaviour.None) { sb.AddLine(helper.Href(fileLine.Compose(EntityBaseKeys.Link), value?.FileName, hasEntity ? FilesClient.GetDownloadUrl(value) : null, value?.FileName, "form-control file-control", fileLine.Download == DownloadBehaviour.View ? null : new Dictionary <string, object> { { "download", value?.FileName } })); } else { sb.AddLine(helper.Span(fileLine.Compose(EntityBaseKeys.ToStr), value?.FileName ?? "", "form-control file-control", null)); } if (fileLine.Type.IsEmbeddedEntity()) { sb.AddLine(helper.Hidden(fileLine.Compose(EntityBaseKeys.EntityState), value?.Let(f => Navigator.Manager.SerializeEntity((ModifiableEntity)f)))); } using (sb.SurroundLine(new HtmlTag("span", fileLine.Compose("shownButton")).Class("input-group-btn"))) { sb.AddLine(EntityButtonHelper.Remove(helper, fileLine, btn: true)); } } sbg.AddLine(helper.FormGroup(fileLine, fileLine.Download == DownloadBehaviour.None ? fileLine.Compose(EntityBaseKeys.Link) : fileLine.Compose(EntityBaseKeys.ToStr), fileLine.LabelHtml ?? fileLine.LabelText.FormatHtml(), sb.ToHtml())); } using (sbg.SurroundLine(new HtmlTag("div", fileLine.Compose("DivNew")) .Class("sf-file-line-new") .Attr("style", "display:" + (hasEntity ? "none" : "block")))) { HtmlStringBuilder sb = new HtmlStringBuilder(); sb.AddLine(helper.HiddenRuntimeInfo(fileLine)); if (!fileLine.ReadOnly) { sb.AddLine(MvcHtmlString.Create("<input type='file' id='{0}' name='{0}' class='form-control'/>".FormatWith(fileLine.Compose(FileLineKeys.File)))); sb.AddLine(MvcHtmlString.Create("<img src='{0}' id='{1}_loading' alt='loading' style='display:none'/>".FormatWith(RouteHelper.New().Content("~/Files/Images/loading.gif"), fileLine.Prefix))); } sbg.AddLine(helper.FormGroup(fileLine, fileLine.Compose(FileLineKeys.File), fileLine.LabelHtml ?? fileLine.LabelText.FormatHtml(), sb.ToHtml())); } if (!fileLine.ReadOnly) { sbg.AddLine(fileLine.ConstructorScript(FilesClient.Module, "FileLine")); } } return(sbg.ToHtml()); }
protected void btnSaveAccount_Click(object sender, EventArgs e) { string errorMessage = validate(); if (errorMessage.Length == 0) { bool isNew = _account.IsNew; _account.Name = txtAcctName.Text.Trim(); _account.AccountNo = txtAcctNo.Text.Trim().Length > 0 ? txtAcctNo.Text.Trim() : null; _account.Address1 = txtAddress1.Text.Trim().Length > 0 ? txtAddress1.Text.Trim() : null; _account.Address2 = txtAddress2.Text.Trim().Length > 0 ? txtAddress2.Text.Trim() : null; _account.City = txtCity.Text.Trim().Length > 0 ? txtCity.Text.Trim() : null; _account.State = ddlState.SelectedValue.Length > 0 ? ddlState.SelectedValue : null;; _account.ZipCode = txtZip.Text.Trim().Length > 0 ? txtZip.Text.Trim() : null; _account.Phone = txtPhone.Text.Trim().GetNumbers().Length > 0 ? txtPhone.Text.Trim().GetNumbers() : null; _account.IsActive = true; _account.MainContact = txtMainContact.Text.Trim().Length > 0 ? txtMainContact.Text.Trim() : null; _account.Notes = txtNotes.Text.Trim().Length > 0 ? txtNotes.Text.Trim() : null; _account.Save(); var i = 0; foreach (var item in ((IEnumerable <ServiceLocationEntity>)rgServiceLocations.DataSource)) { item.Ordinal = i++; item.Save(); } if (isNew) { _assetReclamationServiceLocation = new ServiceLocationEntity(); _assetReclamationServiceLocation.Account = _account; //_assetReclamationServiceLocation.Name = "Primary Dock"; _assetReclamationServiceLocation.Name = _account.Name; _assetReclamationServiceLocation.Address1 = _account.Address1; _assetReclamationServiceLocation.Address2 = _account.Address2; _assetReclamationServiceLocation.City = _account.City; _assetReclamationServiceLocation.ZipCode = _account.ZipCode; _assetReclamationServiceLocation.MainContact = _account.MainContact; _assetReclamationServiceLocation.Notes = _account.Notes; _assetReclamationServiceLocation.Phone = _account.Phone; _assetReclamationServiceLocation.ServiceTypeId = (int)ServiceTypeEntity.ServiceTypes.AssetReclamationOnly; _assetReclamationServiceLocation.Save(); // create service location _recycleServiceLocation = new ServiceLocationEntity(); _recycleServiceLocation.Account = _account; _recycleServiceLocation.Name = "Primary Dock"; _recycleServiceLocation.Address1 = _account.Address1; _recycleServiceLocation.Address2 = _account.Address2; _recycleServiceLocation.City = _account.City; _recycleServiceLocation.ZipCode = _account.ZipCode; _recycleServiceLocation.MainContact = _account.MainContact; _recycleServiceLocation.Notes = _account.Notes; _recycleServiceLocation.Phone = _account.Phone; _recycleServiceLocation.ServiceTypeId = (int)ServiceTypeEntity.ServiceTypes.RecycleOnly; _recycleServiceLocation.Save(); } Response.Redirect("~/EditAccount.aspx?acctId=" + _account.AccountId.ToString()); } else { messages.Controls.Add(HtmlHelper.Div("error", errorMessage)); } }
private static MvcHtmlString InternalEntityListDetail <T>(this HtmlHelper helper, EntityListDetail listDetail) { if (!listDetail.Visible || listDetail.HideIfNull && listDetail.UntypedValue == null) { return(MvcHtmlString.Empty); } HtmlStringBuilder sb = new HtmlStringBuilder(); using (sb.SurroundLine(new HtmlTag("div", listDetail.Prefix).Class("SF-entity-list-detail SF-control-container"))) { sb.AddLine(helper.Hidden(listDetail.Compose(EntityListBaseKeys.ListPresent), "")); using (sb.SurroundLine(new HtmlTag("div", listDetail.Compose("hidden")).Class("hide"))) { } HtmlStringBuilder sbSelect = new HtmlStringBuilder(); var sbSelectContainer = new HtmlTag("select").Attr("size", "6").Class("form-control") .IdName(listDetail.Compose(EntityListBaseKeys.List)); if (listDetail.ListHtmlProps.Any()) { sbSelectContainer.Attrs(listDetail.ListHtmlProps); } using (sbSelect.SurroundLine(sbSelectContainer)) { if (listDetail.UntypedValue != null) { foreach (var itemTC in TypeContextUtilities.TypeElementContext((TypeContext <MList <T> >)listDetail.Parent)) { sb.Add(InternalListDetailElement(helper, sbSelect, itemTC, listDetail)); } } } using (sb.SurroundLine(new HtmlTag("div", listDetail.Compose("inputGroup")).Class("input-group"))) { sb.Add(sbSelect.ToHtml()); using (sb.SurroundLine(new HtmlTag("span", listDetail.Compose("shownButton")).Class("input-group-btn btn-group-vertical"))) { sb.AddLine(EntityButtonHelper.Create(helper, listDetail, btn: true)); sb.AddLine(EntityButtonHelper.Find(helper, listDetail, btn: true)); sb.AddLine(EntityButtonHelper.Remove(helper, listDetail, btn: true)); sb.AddLine(EntityButtonHelper.MoveUp(helper, listDetail, btn: true)); sb.AddLine(EntityButtonHelper.MoveDown(helper, listDetail, btn: true)); } } if (listDetail.ElementType.IsEmbeddedEntity() && listDetail.Create) { T embedded = (T)(object)new ConstructorContext(helper.ViewContext.Controller).ConstructUntyped(typeof(T)); TypeElementContext <T> templateTC = new TypeElementContext <T>(embedded, (TypeContext)listDetail.Parent, 0, null); sb.AddLine(EntityBaseHelper.EmbeddedTemplate(listDetail, EntityBaseHelper.RenderContent(helper, templateTC, RenderContentMode.Content, listDetail), templateTC.Value.ToString())); } sb.AddLine(listDetail.ConstructorScript(JsModule.Lines, "EntityListDetail")); } var formGroup = helper.FormGroup(listDetail, listDetail.Prefix, listDetail.LabelHtml ?? listDetail.LabelText.FormatHtml(), sb.ToHtml()); if (listDetail.DetailDiv != listDetail.Compose(EntityBaseKeys.Detail)) { return(formGroup); } HtmlStringBuilder sb2 = new HtmlStringBuilder(); sb2.Add(formGroup); using (sb2.SurroundLine(new HtmlTag("fieldset"))) sb2.AddLine(helper.Div(listDetail.DetailDiv, null, "SF-entity-list-detail-detaildiv")); return(sb2.ToHtml()); }
private static MvcHtmlString InternalRepeaterElement <T>(this HtmlHelper helper, TypeElementContext <T> itemTC, EntityListCheckbox entityListCheckBox, bool isChecked, Lite <IEntity> lite) { HtmlStringBuilder sb = new HtmlStringBuilder(); var label = new HtmlTag("label", itemTC.Compose(EntityRepeaterKeys.RepeaterElement)).Class("sf-checkbox-element"); entityListCheckBox.CustomizeLabel?.Invoke(label, lite); using (sb.SurroundLine(label)) { if (EntityBaseHelper.EmbeddedOrNew((Modifiable)(object)itemTC.Value)) { sb.AddLine(EntityBaseHelper.RenderPopup(helper, itemTC, RenderPopupMode.PopupInDiv, entityListCheckBox)); } else if (itemTC.Value != null) { sb.Add(helper.Div(itemTC.Compose(EntityBaseKeys.Entity), null, "", new Dictionary <string, object> { { "style", "display:none" }, { "class", "sf-entity-list" } })); } var cb = new HtmlTag("input") .Attr("type", "checkbox") .Attr("name", itemTC.Compose(EntityBaseKeys.RuntimeInfo)) .Attr("value", itemTC.RuntimeInfo()?.ToString()); if (isChecked) { cb.Attr("checked", "checked"); } if (entityListCheckBox.ReadOnly) { cb.Attr("disabled", "disabled"); } entityListCheckBox.CustomizeCheckBox?.Invoke(cb, lite); sb.AddLine(cb); if (lite != null && (entityListCheckBox.Navigate || entityListCheckBox.View)) { var dic = new Dictionary <string, object> { { "target", "_blank" } }; sb.AddLine( helper.Href(itemTC.Compose(EntityBaseKeys.Link), lite.ToString(), lite.IdOrNull == null ? null : Navigator.NavigateRoute(lite), lite.ToString(), "sf-entitStrip-link", dic)); } else { sb.AddLine( helper.Span(itemTC.Compose(EntityBaseKeys.Link), itemTC.UntypedValue.ToString() ?? " ", "sf-entitStrip-link")); } } return(sb.ToHtml()); }
protected void btnSaveSchedule_Click(object sender, EventArgs e) { SaveAssignments(); populate(); messages.Add(HtmlHelper.Div("success", "Schedule Saved")); }