void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { if (ViewState[Editor] != null) { Controls.Add( new LiteralControl("<span class=\"Normal\">" + ModuleSecurity.BestUserName(ViewState[Editor].ToString(), PortalId) + "</span>")); } } }
public override void RenderValuesToHtmlInsideDataSet(DataSet ds, int moduleId, bool noScript) { var colCreatedBy = new ArrayList(); var tableData = ds.Tables[DataSetTableName.Data]; var asLink = false; var openInNewWindow = false; var preferDisplayName = false; foreach (DataRow row in ds.Tables[DataSetTableName.Fields].Rows) { if (row[FieldsTableColumn.Type].ToString() == Name) { var fieldId = (int)row[FieldsTableColumn.Id]; asLink = GetFieldSetting("AsLink", fieldId, ds).AsBoolean( ); openInNewWindow = GetFieldSetting("OpenInNewWindow", fieldId, ds).AsBoolean(); preferDisplayName = GetFieldSetting("PreferDisplayName", fieldId, ds).AsBoolean(); var title = row[FieldsTableColumn.Title].ToString(); colCreatedBy.Add(title); tableData.Columns.Add(new DataColumn(title + DataTableColumn.Appendix_Original, typeof(string))); tableData.Columns.Add(new DataColumn(title + DataTableColumn.Appendix_Caption, typeof(string))); tableData.Columns.Add(new DataColumn(title + DataTableColumn.Appendix_Url, typeof(string))); } } if (colCreatedBy.Count > 0) { var portalId = Null.NullInteger; var tabId = Null.NullInteger; if (HttpContext.Current != null) { var portalSettings = PortalController.Instance.GetCurrentPortalSettings(); portalId = portalSettings.PortalId; tabId = portalSettings.ActiveTab.TabID; } foreach (DataRow row in tableData.Rows) { foreach (string fieldName in colCreatedBy) { var strCreatedBy = row[fieldName].ToString(); var strCaption = strCreatedBy; var strUrl = string.Empty; if (!preferDisplayName) { strCaption = ModuleSecurity.BestUserName(strCreatedBy, portalId); } if (asLink) { var userId = ModuleSecurity.UserId(strCreatedBy, portalId); if (userId > 0) { strUrl = HttpUtility.HtmlEncode(Globals.LinkClick(("userid=" + userId), tabId, moduleId)); } } string strFieldvalue; if (asLink && strUrl != string.Empty) { strFieldvalue = string.Format("<!--{1}--><a href=\"{0}\"{2}>{1}</a>", strUrl, strCaption, (openInNewWindow ? " target=\"_blank\"" : "")); } else { strFieldvalue = strCaption; } row[fieldName] = strFieldvalue; row[fieldName + DataTableColumn.Appendix_Original] = strCreatedBy; row[fieldName + DataTableColumn.Appendix_Caption] = strCaption; if (strUrl != string.Empty) { row[fieldName + DataTableColumn.Appendix_Url] = strUrl; } } } } }