public void RecuperaDadosInternacao(int varIDInternacao) { //Acessando a lista Visita SPList lstInternacao = web.Lists["Internações"]; //Construindo a Query CAML SPQuery oQuery = new SPQuery(); oQuery.Query = "<Where>" + "<Eq>" + "<FieldRef Name='ID' /><Value Type='Number'>" + intIDInternacao + "</Value>" + "</Eq>" + "</Where>"; //Criando uma coleção de itens, utilizando a Query CAML SPListItemCollection collListItems = lstInternacao.GetItems(oQuery); //Recupera o item foreach (SPListItem oListItem in collListItems) { //Guarda resultado nas variáveis strProntuario = SPEncode.HtmlEncode(oListItem["Prontu_x00e1_rio"].ToString()); strPaciente = SPEncode.HtmlEncode(oListItem["Paciente"].ToString()); } }
protected void DebugRender(HtmlTextWriter writer) { SPSEditorPartsTools editorTools = new SPSEditorPartsTools(writer); if (DebugQuery) { string resultQuery = editorTools.FormatXml(CamlQuery); writer.Write("<font color=red>DEBUG CAML Query (Original)</font><br><font color=blue>"); writer.Write("<pre>" + SPEncode.HtmlEncode(resultQuery) + "</pre>"); writer.Write("</font><br>"); resultQuery = editorTools.FormatXml(_camlPreprocessor.Preprocess()); writer.Write("<font color=red>DEBUG CAML Query (Processed)</font><br><font color=blue>"); writer.Write("<pre>" + SPEncode.HtmlEncode(resultQuery) + "</pre>"); writer.Write("</font><br>"); } if (DebugResults) { writer.Write("<font color=red>DEBUG XML DATA</font><br><font color=blue>"); writer.Write("<pre>" + SPEncode.HtmlEncode(editorTools.FormatXml(_rollupEngine.Data.GetXml())) + "</pre>"); writer.Write("</font><br>"); } if (DebugEvaluator) { writer.Write("<font color=red>DEBUG Evaluator</font><br>"); writer.Write(EvaluatorSample()); writer.Write("<br>"); } }
public string RecuperaDadosMedico(string strMedico) { strMedico = strMedico.Substring(strMedico.IndexOf("#") + 1); string strEspecialidade = ""; //Acessando a lista Visita SPList lstMedico = web.Lists["Medicos"]; //Construindo a Query CAML SPQuery oQuery = new SPQuery(); oQuery.Query = "<Where>" + "<Eq>" + "<FieldRef Name='Title' /><Value Type='Text'>" + strMedico + "</Value>" + "</Eq>" + "</Where>"; //Criando uma coleção de itens, utilizando a Query CAML SPListItemCollection collListItems = lstMedico.GetItems(oQuery); //Recupera o item foreach (SPListItem oListItem in collListItems) { strEspecialidade = oListItem["Especialidade"].ToString() != null?SPEncode.HtmlEncode(oListItem["Especialidade"].ToString()) : ""; } return(strEspecialidade); }
/// <summary> /// Render this Tool part to the output parameter /// specified. /// </summary> /// <param name="output"> /// The HTML writer to write out to /// </param> protected override void RenderToolPart(HtmlTextWriter output) { // Establish a reference to the Web Part. SharePointForumWebPart wp1 = (SharePointForumWebPart)this.ParentToolPane.SelectedWebPart; output.Write("Enter your custom text: "); output.Write("<input name= '" + inputname); output.Write("' type='text' value='" + SPEncode.HtmlEncode(ForumApplication.Instance.Title) + "'> <br>"); }
protected override void RenderFieldForDisplay(HtmlTextWriter writer) { if (SPContext.Current.FormContext.FormMode == SPControlMode.New) { writer.Write(" "); } else { writer.Write(ItemFieldValue == null ? " " : SPEncode.HtmlEncode(ItemFieldValue.ToString())); } }
public override string GetCellTextValue(DataRow row) { var value = row[FieldName]; if (value is DBNull) { return(DefaultValue); } return(SPEncode.HtmlEncode(value.ToString())); }
public virtual void RenderCell(HtmlTextWriter writer, IGrouping <object, DataRow> grouping) { var groupKey = Convert.ToString(grouping.Key); if (string.IsNullOrEmpty(groupKey)) { groupKey = EmptyGroupString; } writer.Write(SPEncode.HtmlEncode(groupKey)); }
public override void RenderCell(HtmlTextWriter writer, DataRow row) { var value = Convert.ToString(row[FieldName]); if (string.IsNullOrEmpty(value)) { writer.Write(DefaultValue); return; } value = SPEncode.HtmlEncode(value); var split = value.Split(new[] { ";#" }, StringSplitOptions.RemoveEmptyEntries); writer.Write(string.Join("; ", split)); }
/// <summary> /// Debugs the render. /// </summary> /// <param name="writer">The writer.</param> /// <param name="transformed">The transformated.</param> internal void DebugRender(HtmlTextWriter writer, string transformed) { SPSEditorPartsTools tools = new SPSEditorPartsTools(writer); //if (DebugSource) //{ // writer.Write("<font color=red>DEBUG XML DATA</font><br><font color=blue>"); // writer.Write("<pre>" + SPEncode.HtmlEncode(tools.FormatXml(XmlData)) + "</pre>"); // writer.Write("</font><br>"); //} if (DebugTransformation) { writer.Write("<font color=red>DEBUG XML TRANSFORM</font><br><font color=blue>"); writer.Write("<pre>" + SPEncode.HtmlEncode(tools.FormatXml(transformed)) + "</pre>"); writer.Write("</font><br>"); } }
public void MontaListaVisita(int varIDInternacao) { string varLinha = ""; lblProntuario.Text = strProntuario.ToString(); lblPaciente.Text = strPaciente.ToString(); //Acessando a lista Visita SPList lstVisita = web.Lists["Visitas"]; //Construindo a Query CAML SPQuery oQuery = new SPQuery(); oQuery.Query = "<Where>" + "<Eq>" + "<FieldRef Name='Registro_x0020_de_x0020_interna_' /><Value Type='Lookup'>" + intIDInternacao + "</Value>" + "</Eq>" + "</Where>"; //Criando uma coleção de itens, utilizando a Query CAML SPListItemCollection collListItems = lstVisita.GetItems(oQuery); //Recupera o item foreach (SPListItem oListItem in collListItems) { //Busca Especialidade do médico da visita string strEspecMedico = RecuperaDadosMedico(SPEncode.HtmlEncode(oListItem["M_x00e9_dico_x0020_da_x0020_Visi"].ToString())); //Monta linha da grid com os resultados varLinha += "<tr><td valign='top' class='ms-formbody'>" + oListItem["M_x00e9_dico_x0020_da_x0020_Visi"] != null?SPEncode.HtmlEncode(oListItem["M_x00e9_dico_x0020_da_x0020_Visi"].ToString()) : "" + "</td>" + "<td valign='top' class='ms-formbody'>" + SPEncode.HtmlEncode(strEspecMedico.ToString()) + "</td>" + "<td valign='top' class='ms-formbody'>" + oListItem["Tipo_x0020_de_x0020_Visita"] != null?SPEncode.HtmlEncode(oListItem["Tipo_x0020_de_x0020_Visita"].ToString()) : "" + "</td>" + "<td valign='top' class='ms-formbody'>" + oListItem["Hora_x0020_de_x0020_In_x00ed_cio"] != null?SPEncode.HtmlEncode(oListItem["Hora_x0020_de_x0020_In_x00ed_cio"].ToString()) : "" + "</td>" + "<td valign='top' class='ms-formbody'>" + oListItem["Hora_x0020_de_x0020_Fim_x0020_da"] != null?SPEncode.HtmlEncode(oListItem["Hora_x0020_de_x0020_Fim_x0020_da"].ToString()) : "" + "</td>" + "<td valign='top' class='ms-formbody'>" + oListItem["Observa_x00e7__x00e3_o"] != null?SPEncode.HtmlEncode(oListItem["Observa_x00e7__x00e3_o"].ToString()) : "" + "</td></tr>"; } ltrListaVisita.Text = varLinha.ToString(); }
/// <summary> /// Updates the purchase order info. /// </summary> /// <param name="edc">The object <see cref="Entities.EntitiesDataContext" /> containing entities.</param> /// <param name="excludedLoadDescription">The <see cref="Entities.LoadDescription" /> object that should be exluded from the list of of load descriptions</param> /// <param name="includedLoadDescription">The <see cref="Entities.LoadDescription" /> object that should be included from the list of load descriptions</param> public void UpdateLoadDescriptionInfo(Entities.EntitiesDataContext edc, Entities.LoadDescription excludedLoadDescription, Entities.LoadDescription includedLoadDescription) { this.PoLastModification = DateTime.Now; StringBuilder _po = new StringBuilder(); this.EuroPalletsQuantity = 0; this.InduPalletsQuantity = 0; foreach (LoadDescription _ldx in LoadDescriptions(edc)) { if (excludedLoadDescription == _ldx) { continue; } switch (_ldx.PalletType.GetValueOrDefault(PalletType.None)) { case PalletType.Euro: this.EuroPalletsQuantity += _ldx.NumberOfPallets.GetValueOrDefault(0); break; case PalletType.Industrial: this.InduPalletsQuantity += _ldx.NumberOfPallets.GetValueOrDefault(0); break; case PalletType.None: case PalletType.Other: break; } _po.AppendLine(SPEncode.HtmlEncode(_ldx.Title)); } if (includedLoadDescription != null) { this.EuroPalletsQuantity += includedLoadDescription.PalletType.GetValueOrDefault(PalletType.None) == PalletType.Euro ? includedLoadDescription.NumberOfPallets.GetValueOrDefault(0) : 0; this.InduPalletsQuantity += includedLoadDescription.PalletType.GetValueOrDefault(PalletType.None) == PalletType.Industrial ? includedLoadDescription.NumberOfPallets.GetValueOrDefault(0) : 0; _po.AppendLine(SPEncode.HtmlEncode(includedLoadDescription.Title)); } this.PoNumberMultiline = _po.ToString(); }
public override void RenderCell(HtmlTextWriter writer, DataRow row) { var value = Convert.ToString(row[FieldName]); writer.Write(string.IsNullOrEmpty(value) ? DefaultValue : SPEncode.HtmlEncode(value)); }
protected override void RenderFieldForDisplay(HtmlTextWriter writer) { if (ItemFieldValue == null) { writer.Write(" "); return; } if (IsLookupField) { var web = SPContext.Current.Web; if (ItemFieldValue is SPFieldUserValueCollection) { var users = (SPFieldUserValueCollection)ItemFieldValue; writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.RenderBeginTag(HtmlTextWriterTag.Table); foreach (var user in users) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-vb"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "GoToLinkOrDialogNewWindow(this);return false;"); writer.AddAttribute(HtmlTextWriterAttribute.Href, string.Format("/_layouts/userdisp.aspx?ID={0}", user.LookupId)); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write(SPEncode.HtmlEncode(user.LookupValue)); writer.RenderEndTag(); // a writer.RenderEndTag(); // td writer.RenderEndTag(); // tr } writer.RenderEndTag(); // table return; } if (ItemFieldValue is SPFieldLookupValueCollection) { var field = (SPFieldLookup)Field; var list = web.Lists[new Guid(field.LookupList)]; var lookups = (SPFieldLookupValueCollection)ItemFieldValue; for (var index = 0; index < lookups.Count; index++) { var lookup = lookups[index]; writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "GoToLinkOrDialogNewWindow(this);return false;"); writer.AddAttribute(HtmlTextWriterAttribute.Href, string.Format("{0}{1}?ID={2}", web.Url, list.DefaultDisplayFormUrl, lookup.LookupId)); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write(SPEncode.HtmlEncode(lookup.LookupValue)); writer.RenderEndTag(); // a if (index < lookups.Count - 1) { writer.Write("; "); } } return; } var split = ItemFieldValue.ToString().Split(new [] { ";#" }, StringSplitOptions.None); if (Field is SPFieldUser) { writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "GoToLinkOrDialogNewWindow(this);return false;"); writer.AddAttribute(HtmlTextWriterAttribute.Href, string.Format("/_layouts/userdisp.aspx?ID={0}", split[0])); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write(SPEncode.HtmlEncode(split[1])); writer.RenderEndTag(); // a } else { var field = (SPFieldLookup)Field; var list = web.Lists[new Guid(field.LookupList)]; writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "GoToLinkOrDialogNewWindow(this);return false;"); writer.AddAttribute(HtmlTextWriterAttribute.Href, string.Format("{0}{1}?ID={2}", web.Url, list.DefaultDisplayFormUrl, split[1])); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write(SPEncode.HtmlEncode(split[1])); writer.RenderEndTag(); // a } } else { var values = Convert.ToString(ItemFieldValue).Split(new[] { ";#", "; ", "\r\n", "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries).ToList(); writer.Write(MultiLine ? string.Join("<br/>", values.Select(SPEncode.HtmlEncode).ToArray()) : string.Join("; ", values.Select(SPEncode.HtmlEncode).ToArray())); } }
void BuildTree() { try { XmlElement current = null; if (!string.IsNullOrEmpty(this.RootTitleUrl)) { string iconUrl = "/_layouts/15/images/STSICON.GIF"; string webDescription = ""; string webID = "rootid"; string webTitle = string.IsNullOrEmpty(this.RootTitle) ? this.RootTitleUrl : this.RootTitle; try { using (SPSite site = new SPSite(this.RootTitleUrl)) { using (SPWeb web = site.OpenWeb()) { string iconFile = web.Properties["treeicon"]; if (iconFile != null && iconFile != "") { iconUrl = iconFile; } webDescription = web.Description; webID = web.ID.ToString(); webTitle = string.IsNullOrEmpty(this.RootTitle) ? web.Title : this.RootTitle; } } } catch { } current = this.theTreeControl.AddNode(ref current, webTitle, webDescription, webID, iconUrl, true, TreeItemState.Unselected, SPEncode.HtmlEncode(this.RootTitleUrl), "", "", ""); //foreach (SPWeb sub in this.treeRootWeb.GetSubwebsForCurrentUser()) // BuildTree(current, sub, level + 1); } //else //{ // BuildTree(current, this.treeRootWeb, 0); //} foreach (SPWeb treeRootWeb in this.treeRootWebs) { int level = 0; if (!this.ShowRootSites) { foreach (SPWeb sub in treeRootWeb.GetSubwebsForCurrentUser()) { BuildTree(current, sub, level + 1); } } else { BuildTree(current, treeRootWeb, 0); } } } catch (Exception ex) { AddError(ex); } }
private void RenderFolderCreator(HtmlTextWriter writer) { var controlMode = SPContext.Current.FormContext.FormMode; writer.AddAttribute(HtmlTextWriterAttribute.Id, "part1"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formtable"); writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.AddStyleAttribute(HtmlTextWriterStyle.MarginTop, "8px"); writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); // Td writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formlabel"); writer.AddAttribute(HtmlTextWriterAttribute.Width, "190px"); writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-standardheader"); writer.RenderBeginTag(HtmlTextWriterTag.H3); writer.Write("Name"); if (controlMode != SPControlMode.Display) { writer.AddAttribute(HtmlTextWriterAttribute.Title, "This is a required field."); writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formvalidation"); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(" *"); writer.RenderEndTag(); // span } writer.RenderEndTag(); // h3 writer.RenderEndTag(); // td // Td writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formbody"); writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top"); writer.RenderBeginTag(HtmlTextWriterTag.Td); SPListItem folder = null; if (controlMode != SPControlMode.New) { folder = SPContext.Current.List.GetItemById(Convert.ToInt32(Page.Request.QueryString["ID"])); } if (controlMode == SPControlMode.Display) { var viewUrl = Page.Request.QueryString["Source"]; if (string.IsNullOrEmpty(viewUrl)) { viewUrl = SPContext.Current.List.DefaultViewUrl; } var urlBuilder = new UrlBuilder(viewUrl); urlBuilder.ClearQueryString(); // ReSharper disable PossibleNullReferenceException urlBuilder.AddQueryString("RootFolder", folder.Folder.ServerRelativeUrl); // ReSharper restore PossibleNullReferenceException writer.AddAttribute(HtmlTextWriterAttribute.Rel, "sp_DialogLinkNavigate"); writer.AddAttribute(HtmlTextWriterAttribute.Href, urlBuilder.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write(SPEncode.HtmlEncode(folder.Name)); writer.RenderEndTag(); // a } else { writer.RenderBeginTag(HtmlTextWriterTag.Span); if (!Page.IsPostBack && SPContext.Current.FormContext.FormMode == SPControlMode.Edit) { // ReSharper disable PossibleNullReferenceException writer.AddAttribute(HtmlTextWriterAttribute.Value, folder.Name); // ReSharper restore PossibleNullReferenceException } else { writer.AddAttribute(HtmlTextWriterAttribute.Value, folderName); } writer.AddAttribute(HtmlTextWriterAttribute.Title, "Name"); writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-long"); writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID + "$onetidIOFile"); writer.RenderBeginTag(HtmlTextWriterTag.Input); if (!IsValid) { writer.Write("<br/>"); writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formvalidation"); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.AddAttribute("role", "alert"); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(ErrorMessage); writer.RenderEndTag(); // span writer.RenderEndTag(); // span } writer.RenderEndTag(); // input writer.RenderEndTag(); // span } writer.RenderEndTag(); // td writer.RenderEndTag(); // tr writer.RenderEndTag(); // table // Table writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formline"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.Write("<img width=\"1\" height=\"1\" alt=\"\" src=\"/_layouts/15/images/blank.gif\" complete=\"complete\"/>"); writer.RenderEndTag(); // td writer.RenderEndTag(); // tr writer.RenderEndTag(); // table // Table writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddStyleAttribute(HtmlTextWriterStyle.PaddingTop, "7px"); writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); writer.RenderBeginTag(HtmlTextWriterTag.Td); // Table writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formtoolbar"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "2"); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); // Td writer.RenderBeginTag(HtmlTextWriterTag.Td); if (controlMode == SPControlMode.New) { writer.Write(" "); } else { createdModifiedInfo.ControlMode = controlMode; createdModifiedInfo.RenderControl(writer); } writer.RenderEndTag(); // td // Td writer.AddAttribute(HtmlTextWriterAttribute.Width, "99%"); writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-toolbar"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.Write("<img width=\"1\" height=\"18\" alt=\"\" src=\"/_layouts/15/images/blank.gif\" complete=\"complete\"/>"); writer.RenderEndTag(); // td if (controlMode == SPControlMode.Display) { // Td writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-toolbar"); writer.RenderBeginTag(HtmlTextWriterTag.Td); RenderButton(writer, "Close", "C", "SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, null);"); writer.RenderEndTag(); // td } else { // Td writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-toolbar"); writer.RenderBeginTag(HtmlTextWriterTag.Td); RenderButton(writer, "Save", "O", Page.ClientScript.GetPostBackEventReference(this, "ADD_OR_EDIT_FOLDER")); writer.RenderEndTag(); // td // Td writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-separator"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.Write(" "); writer.RenderEndTag(); // td // Td writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-toolbar"); writer.RenderBeginTag(HtmlTextWriterTag.Td); RenderButton(writer, "Cancel", "C", "SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, null);"); writer.RenderEndTag(); // td } writer.RenderEndTag(); // tr writer.RenderEndTag(); // table writer.RenderEndTag(); // td writer.RenderEndTag(); // tr writer.RenderEndTag(); // table writer.RenderEndTag(); // div writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript"); writer.RenderBeginTag(HtmlTextWriterTag.Script); writer.Write("SetUploadPageTitle();"); writer.RenderEndTag(); // script }
void BuildTree(XmlElement parent, SPWeb web, int level) { TreeItemState state = TreeItemState.Unselected; if (web.ID == this.currentWeb.ID) { state = TreeItemState.Selected; this.theTreeControl.ExpandParentNodes(parent); } bool isExpanded = level < this.ExpandLevels; string iconUrl = "/_layouts/15/images/STSICON.GIF"; try { string iconFile = web.Properties["treeicon"]; if (iconFile != null && iconFile != "") { iconUrl = iconFile; } } catch {} string title = web.Title; if (this.ShowDescription && !string.IsNullOrEmpty(web.Description)) { title += " - " + web.Description; } XmlElement current = this.theTreeControl.AddNode(ref parent, title, web.Description, web.ID.ToString(), iconUrl, isExpanded, state, SPEncode.HtmlEncode(web.Url), "", "", "SNT_GetChildren('" + web.ID.ToString("D") + "','" + theTreeControl.ValidScriptClientID + "');"); if (this.theTreeControl.IsNodeOpen(ref current)) { foreach (SPWeb sub in web.GetSubwebsForCurrentUser()) { BuildTree(current, sub, level + 1); } } else if (web.GetSubwebsForCurrentUser().Count > 0) { this.theTreeControl.AddDummyNode(ref current); } }
protected override void RenderFieldForInput(HtmlTextWriter writer) { var options = GetSelectOptions(); var value = Convert.ToString(Value); if (!Page.IsPostBack && ControlMode == SPControlMode.New) { value = DefaultValue; } if (!string.IsNullOrEmpty(value)) { if (!options.Contains(value)) { fillInChoiceSelected = true; } } var fillInChoice = FillInChoice; writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.RenderBeginTag(HtmlTextWriterTag.Table); // Tr writer.RenderBeginTag(HtmlTextWriterTag.Tr); if (fillInChoice) { writer.RenderBeginTag(HtmlTextWriterTag.Td); if (!fillInChoiceSelected) { writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked"); } writer.AddAttribute(HtmlTextWriterAttribute.Title, string.Format("{0}: {1}", Field.Title, SPResource.GetString("DropDownChoiceButtonToolTip"))); writer.AddAttribute(HtmlTextWriterAttribute.Value, "DropDownButton"); writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID + "$FillInChoice"); writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID + "_DropDownButton"); writer.AddAttribute(HtmlTextWriterAttribute.Type, "radio"); writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); // input writer.RenderEndTag(); // td } writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID); writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID); writer.AddAttribute(HtmlTextWriterAttribute.Title, Field.Title); writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-RadioText"); if (fillInChoice) { writer.AddAttribute(HtmlTextWriterAttribute.Onclick, string.Format("document.getElementById('{0}_DropDownButton').checked = true;", ClientID)); } if (AutoPostBack) { writer.AddAttribute(HtmlTextWriterAttribute.Onchange, Page.ClientScript.GetPostBackEventReference(this, null)); } writer.RenderBeginTag(HtmlTextWriterTag.Select); foreach (var option in options) { if (String.Equals(option, value, StringComparison.InvariantCultureIgnoreCase)) { writer.AddAttribute(HtmlTextWriterAttribute.Selected, "selected"); } writer.AddAttribute(HtmlTextWriterAttribute.Value, SPEncode.HtmlEncode(option)); writer.RenderBeginTag(HtmlTextWriterTag.Option); writer.Write(SPEncode.HtmlEncode(option)); writer.RenderEndTag(); } writer.RenderEndTag(); // select writer.RenderEndTag(); // td writer.RenderEndTag(); // tr if (fillInChoice) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.RenderBeginTag(HtmlTextWriterTag.Td); if (fillInChoiceSelected) { writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked"); } writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID + "_FillInButton"); writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID + "$FillInChoice"); writer.AddAttribute(HtmlTextWriterAttribute.Value, "FillInButton"); writer.AddAttribute(HtmlTextWriterAttribute.Title, string.Format("{0}: {1}", Field.Title, SPResource.GetString("ChoiceFieldFillInChoiceText"))); writer.AddAttribute(HtmlTextWriterAttribute.Type, "radio"); writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); // input writer.RenderEndTag(); // td writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.Write(SPResource.GetString("ChoiceFieldFillInChoiceText", new object[0])); writer.RenderEndTag(); // td writer.RenderEndTag(); // tr writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.Write(" "); writer.RenderEndTag(); // td writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Title, Field.Title); writer.AddAttribute(HtmlTextWriterAttribute.Maxlength, "255"); writer.AddAttribute(HtmlTextWriterAttribute.Type, "text"); writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID + "$FillInChoiceValue"); writer.AddAttribute(HtmlTextWriterAttribute.Onclick, string.Format("document.getElementById('{0}_FillInButton').checked = true;", ClientID)); if (fillInChoiceSelected) { writer.AddAttribute(HtmlTextWriterAttribute.Value, Convert.ToString(Value)); } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); // input writer.RenderEndTag(); // td writer.RenderEndTag(); // tr } writer.RenderEndTag(); // table RenderValidationMessage(writer); }
// Public Methods (1) /// <summary> /// Called when the user clicks the OK or the Apply button in the tool pane. /// </summary> public override void ApplyChanges() { var myWorkWebPart = (MyWorkWebPart)ParentToolPane.SelectedWebPart; string uniqueId = UniqueID.Md5(); string useCentralizedSettings = Page.Request.Form[string.Format(@"cbUseCentralizedSettings_{0}", uniqueId)]; string performanceMode = Page.Request.Form[string.Format(@"cbPerformanceMode_{0}", uniqueId)]; string showToolbar = Page.Request.Form[string.Format(@"cbShowToolbar_{0}", uniqueId)]; string daysAgoEnabled = Page.Request.Form[string.Format(@"cbDaysAgo_{0}", uniqueId)]; string daysAfterEnabled = Page.Request.Form[string.Format(@"cbDaysAfter_{0}", uniqueId)]; string newItemIndicatorEnabled = Page.Request.Form[string.Format(@"cbNewItemIndicator_{0}", uniqueId)]; string daysAgo = Page.Request.Form[string.Format(@"tbDaysAgo_{0}", uniqueId)]; string daysAfter = Page.Request.Form[string.Format(@"tbDaysAfter_{0}", uniqueId)]; string newItemIndicator = Page.Request.Form[string.Format(@"tbNewItemIndicator_{0}", uniqueId)]; string hideNewButton = Page.Request.Form[string.Format(@"cbHideNewButton_{0}", uniqueId)]; string allowEditToggle = Page.Request.Form[string.Format(@"cbAllowEditToggle_{0}", uniqueId)]; string defaultToEditMode = Page.Request.Form[string.Format(@"cbDefaultToEditMode_{0}", uniqueId)]; string selectedLists = Page.Request.Form[string.Format(@"tbLists_{0}", uniqueId)]; string myWorkSelectedLists = Page.Request.Form[string.Format(@"selectedMyWorkLists_{0}", uniqueId)]; string selectedFields = Page.Request.Form[string.Format(@"selectedFields_{0}", uniqueId)]; string crossSiteUrls = Page.Request.Form[string.Format(@"tbCrossSiteUrls_{0}", uniqueId)]; string defaultGlobalView = Page.Request.Form[string.Format(@"defaultGlobalViews_{0}", uniqueId)]; myWorkWebPart.UseCentralizedSettings = !string.IsNullOrEmpty(useCentralizedSettings) && useCentralizedSettings.Equals("on"); myWorkWebPart.PerformanceMode = !string.IsNullOrEmpty(performanceMode) && performanceMode.Equals("on"); myWorkWebPart.ShowToolbar = !string.IsNullOrEmpty(showToolbar) && showToolbar.Equals("on"); string daysAgoValue = string.Empty; string daysAfterValue = string.Empty; if (!string.IsNullOrEmpty(daysAgo)) { string text = daysAgo.Trim(); int days; if (int.TryParse(text, out days)) { if (days > 0) { daysAgoValue = text; } } } if (!string.IsNullOrEmpty(daysAfter)) { string text = daysAfter.Trim(); int days; if (int.TryParse(text, out days)) { if (days > 0) { daysAfterValue = text; } } } string dayFilters = string.Format("{0}|{1}|{2}|{3}", !string.IsNullOrEmpty(daysAgoEnabled) && daysAgoEnabled.Equals("on"), daysAgoValue, !string.IsNullOrEmpty(daysAfterEnabled) && daysAfterEnabled.Equals("on"), daysAfterValue).ToLower(); myWorkWebPart.DueDayFilter = dayFilters; string daysIndicator = string.Empty; if (!string.IsNullOrEmpty(newItemIndicator)) { string text = newItemIndicator.Trim(); int days; if (int.TryParse(text, out days)) { if (days > 0) { daysIndicator = text; } } } myWorkWebPart.NewItemIndicator = string.Format("{0}|{1}", !string.IsNullOrEmpty(newItemIndicatorEnabled) && newItemIndicatorEnabled.Equals("on"), daysIndicator).ToLower(); myWorkWebPart.HideNewButton = !string.IsNullOrEmpty(hideNewButton) && hideNewButton.Equals("on"); myWorkWebPart.AllowEditToggle = !string.IsNullOrEmpty(allowEditToggle) && allowEditToggle.Equals("on"); myWorkWebPart.DefaultToEditMode = !string.IsNullOrEmpty(defaultToEditMode) && defaultToEditMode.Equals("on"); myWorkWebPart.MyWorkSelectedLists = myWorkSelectedLists.Split(','); myWorkWebPart.SelectedLists = selectedLists.Replace("\r\n", ",").Split(',') .Select(list => SPEncode.HtmlEncode(list.Trim())) .ToList() .Distinct() .Where(list => !myWorkWebPart.MyWorkSelectedLists.Contains(list)) .ToArray(); myWorkWebPart.SelectedFields = selectedFields.Split(','); myWorkWebPart.CrossSiteUrls = crossSiteUrls.Replace("\r\n", "|").Split('|').Select(site => SPEncode.HtmlEncode(site.Trim())).ToList(). Distinct().ToArray(); myWorkWebPart.DefaultGlobalView = defaultGlobalView; }
protected override void RenderFieldForInput(HtmlTextWriter writer) { var choices = Choices; if (choices.Count == 0) { choices = ((SPFieldChoice)Field).Choices; } if (choices.Count == 0) { writer.Write(" "); return; } var value = Convert.ToString(Value); if (!Page.IsPostBack && ControlMode == SPControlMode.New) { value = DefaultValue; } var rows = Math.Ceiling((double)choices.Count / Columns); var onClientClick = OnClientClick; if (AutoPostBack) { onClientClick = Page.ClientScript.GetPostBackEventReference(this, null); } writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.RenderBeginTag(HtmlTextWriterTag.Table); var index = 0; var flag = false; for (var i = 1; i <= rows; i++) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); for (var j = 1; j <= Columns; j++) { writer.AddStyleAttribute(HtmlTextWriterStyle.PaddingRight, "10px"); writer.RenderBeginTag(HtmlTextWriterTag.Td); if (index < choices.Count) { var item = choices[index]; writer.AddAttribute(HtmlTextWriterAttribute.Title, SPEncode.HtmlEncode(item)); writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-RadioText"); writer.RenderBeginTag(HtmlTextWriterTag.Span); if (string.Equals(value, item)) { writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked"); flag = true; } else { if (!string.IsNullOrEmpty(onClientClick)) { writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onClientClick); } } writer.AddAttribute(HtmlTextWriterAttribute.Id, string.Format("{0}_{1}", ClientID, index)); writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID); writer.AddAttribute(HtmlTextWriterAttribute.Type, "radio"); writer.AddAttribute(HtmlTextWriterAttribute.Value, SPEncode.HtmlEncode(item)); writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); // input writer.AddAttribute(HtmlTextWriterAttribute.For, string.Format("{0}_{1}", ClientID, index)); writer.RenderBeginTag(HtmlTextWriterTag.Label); writer.Write(SPEncode.HtmlEncode(item)); writer.RenderEndTag(); // label writer.RenderEndTag(); // span } else { // Empty cell writer.Write(" "); } writer.RenderEndTag(); // td index++; } writer.RenderEndTag(); // tr } if (Utilities.Cast <SPFieldChoice>(Field).FillInChoice) { var title = SPResource.GetString(Strings.ChoiceFieldFillInChoiceText); writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddAttribute(HtmlTextWriterAttribute.Colspan, Columns.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-RadioText"); writer.AddAttribute(HtmlTextWriterAttribute.Title, title); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.AddAttribute(HtmlTextWriterAttribute.Id, string.Format("{0}_FillInChoice", ClientID)); writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID); writer.AddAttribute(HtmlTextWriterAttribute.Value, FillInChoiceValue); writer.AddAttribute(HtmlTextWriterAttribute.Type, "radio"); if (!flag) { writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked"); } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); // input writer.AddAttribute(HtmlTextWriterAttribute.For, string.Format("{0}_FillInChoice", ClientID)); writer.RenderBeginTag(HtmlTextWriterTag.Label); writer.Write(title); writer.RenderEndTag(); // label writer.RenderEndTag(); // span writer.RenderEndTag(); // td writer.RenderEndTag(); // tr writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddAttribute(HtmlTextWriterAttribute.Colspan, Columns.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Type, "text"); writer.AddAttribute(HtmlTextWriterAttribute.Title, title); writer.AddAttribute(HtmlTextWriterAttribute.Maxlength, "255"); writer.AddAttribute(HtmlTextWriterAttribute.Name, string.Format("{0}$FillInChoice", UniqueID)); writer.AddAttribute(HtmlTextWriterAttribute.Onclick, string.Format("SetChoiceOption('{0}_FillInChoice')", ClientID)); if (!flag) { writer.AddAttribute(HtmlTextWriterAttribute.Value, SPEncode.HtmlEncode(value)); } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); // input writer.RenderEndTag(); // td writer.RenderEndTag(); // tr } writer.RenderEndTag(); // table RenderValidationMessage(writer); }
protected override void RenderFieldForInput(HtmlTextWriter writer) { var field = (SPFieldMultiChoice)Field; var values = GetChoiceValues(); var rows = Math.Ceiling((double)values.Count / Columns); string postBackEventReference = null; if (AutoPostBack) { postBackEventReference = Page.ClientScript.GetPostBackEventReference(this, null); } writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.RenderBeginTag(HtmlTextWriterTag.Table); var index = 0; for (var i = 1; i <= rows; i++) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); for (var j = 1; j <= Columns; j++) { writer.RenderBeginTag(HtmlTextWriterTag.Td); if (index < values.Count) { writer.AddAttribute(HtmlTextWriterAttribute.Title, values[index]); } writer.RenderBeginTag(HtmlTextWriterTag.Span); if (index < values.Count) { writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID + "_" + index); writer.AddAttribute(HtmlTextWriterAttribute.Type, "checkbox"); writer.AddAttribute(HtmlTextWriterAttribute.Value, SPEncode.HtmlEncode(values[index])); writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID); if (SelectedItems.Contains(values[index])) { writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked"); } else { if (!Page.IsPostBack && ControlMode == SPControlMode.New) { if (values[index].Equals(field.DefaultValue)) { writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked"); } } } if (AutoPostBack) { writer.AddAttribute(HtmlTextWriterAttribute.Onclick, postBackEventReference); } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); writer.AddAttribute(HtmlTextWriterAttribute.For, ClientID + "_" + index); writer.RenderBeginTag(HtmlTextWriterTag.Label); writer.Write(SPEncode.HtmlEncode(values[index])); writer.RenderEndTag(); } else { writer.Write(" "); } writer.RenderEndTag(); // span writer.RenderEndTag(); // td index++; } writer.RenderEndTag(); // tr } if (field.FillInChoice) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddAttribute(HtmlTextWriterAttribute.Colspan, Columns.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Type, "checkbox"); writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID + "_FillInChoice"); writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID + "$FillInChoice"); if (!string.IsNullOrEmpty(fillInValue)) { writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked"); } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); // input writer.AddAttribute(HtmlTextWriterAttribute.For, ClientID + "_FillInChoice"); writer.RenderBeginTag(HtmlTextWriterTag.Label); writer.Write(SPResource.GetString(Strings.ChoiceFieldFillInChoiceText)); writer.RenderEndTag(); writer.RenderEndTag(); // td writer.RenderEndTag(); // tr writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddAttribute(HtmlTextWriterAttribute.Colspan, Columns.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Type, "text"); writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID + "$FillInChoiceValue"); writer.AddAttribute("onfocus", string.Format("SetChoiceOption('{0}_FillInChoice')", ClientID)); writer.AddAttribute(HtmlTextWriterAttribute.Value, fillInValue); writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); // input writer.RenderEndTag(); // td writer.RenderEndTag(); // tr } writer.RenderEndTag(); // table RenderValidationMessage(writer); }
public void getReport() { GridView1.DataSource = null; GridView1.DataBind(); lblError.Visible = false; PHO_Dynamic_Tab_Web_Part ptw = (PHO_Dynamic_Tab_Web_Part)this.Parent; try { SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite oSiteCollection = new SPSite(ptw.GetSiteURL)) { using (SPWeb oWebsite = oSiteCollection.OpenWeb()) { try { SPList list = oWebsite.Lists[ptw.getLibrary]; SPView oView = list.Views[ptw.getViewName]; SPQuery squery = new SPQuery(oView); XmlDocument groupDoc = new XmlDocument(); groupDoc.LoadXml(string.Format("<Query>{0}</Query>", oView.Query)); XmlElement groupBy = (XmlElement)groupDoc.SelectSingleNode("//GroupBy"); groupBy.SetAttribute("Collapse", "FALSE"); string groupedbyFieldName = groupBy.InnerXml; //<FieldRef Name="Color" /> trim bool found = groupedbyFieldName.IndexOf("FALSE") != -1; if (found == true) { groupedbyFieldName = groupedbyFieldName.Remove(0, 16); groupedbyFieldName = groupedbyFieldName.Substring(0, groupedbyFieldName.Length - 22); } else { groupedbyFieldName = groupedbyFieldName.Remove(0, 16); groupedbyFieldName = groupedbyFieldName.Substring(0, groupedbyFieldName.Length - 4); } var listItems = list.GetItems(); // Filter the items in the results to only retain distinct items in an 2D array var k = (from SPListItem xitem in listItems select xitem[groupedbyFieldName]).Distinct().ToArray(); var distinctItems = k.Where(s => s != null).ToArray(); SPField field = list.Fields.GetField(groupedbyFieldName); SPFieldType fieldType = field.Type; uint numberValues = Convert.ToUInt16(distinctItems.Count()); _bID = numberValues; //TRIM GUID FROM THE MANAGED META DATA VALUES if (distinctItems.First().ToString().IndexOf("|", StringComparison.OrdinalIgnoreCase) >= 0) { for (int i = 0; i < distinctItems.Length; i++) { int index = distinctItems[i].ToString().IndexOf('|'); if (index > 0) { distinctItems[i] = distinctItems[i].ToString().Remove(index); } } } if (found == true) { distinctItems = (from a in distinctItems orderby a descending select a).ToArray(); } else if (found == false) { distinctItems = (from a in distinctItems orderby a ascending select a).ToArray(); } if (this.ButtonPanel.Controls.Count == 0) { for (int i = 0; i <= numberValues - 1; i++) { string uniqValue = SPEncode.HtmlEncode(distinctItems.GetValue(i).ToString()); if (distinctItems.First().ToString().IndexOf("#", StringComparison.OrdinalIgnoreCase) >= 0) { int index = uniqValue.IndexOf('#'); if (index > 0) { uniqValue = uniqValue.Remove(0, index + 1); } } else if (distinctItems.First().ToString().IndexOf("|", StringComparison.OrdinalIgnoreCase) >= 0) { int index = uniqValue.IndexOf('|'); if (index > 0) { uniqValue = uniqValue.Remove(0, index + 1); } } Button btn = new Button(); btn.ID = "Button" + i.ToString(); btn.Text = uniqValue; btn.CssClass = "buttonNav"; ButtonPanel.Controls.Add(btn); btn.Click += new EventHandler(btn_Click); //Programmaticaly add button triggers after the button creation //<asp:AsyncPostBackTrigger runat="server" ControlID="Button1" EventName="Click"/> AsyncPostBackTrigger trigger = new AsyncPostBackTrigger(); trigger.ControlID = "Button" + i.ToString(); trigger.EventName = "Click"; this.UpdatePanel1.Triggers.Add(trigger); } } SPQuery tquery = new SPQuery(); string tmp = oView.Query; if (!IsPostBack) //very first load// { if (ptw.getDefaultValue == "") { for (int i = 0; i < 1; i++) { Button btn = (Button)ButtonPanel.FindControl("Button" + i.ToString()); btn.CssClass = "buttonNav2"; } string f = distinctItems.First().ToString(); int index = f.IndexOf('#'); if (index > 0) { f = f.Remove(0, index + 1); } tmp = "<Where><Eq><FieldRef Name='" + groupedbyFieldName + "' /><Value Type='" + fieldType + "'>" + f + "</Value></Eq></Where>" + tmp; } else { //Change css for the selected tab int t = Convert.ToInt16(_bID); for (int i = 0; i < t; i++) { string r = SPEncode.HtmlEncode(distinctItems.GetValue(i).ToString()); int index = r.IndexOf('#'); if (index > 0) { r = r.Remove(0, index + 1); } if (r == ptw.getDefaultValue) { Button btn = (Button)ButtonPanel.FindControl("Button" + i.ToString()); btn.CssClass = "buttonNav2"; break; } tmp = "<Where><Eq><FieldRef Name='" + groupedbyFieldName + "' /><Value Type='" + fieldType + "'>" + r + "</Value></Eq></Where>" + tmp; } } } else { //not first load// tmp = "<Where><Eq><FieldRef Name='" + groupedbyFieldName + "' /><Value Type='" + fieldType + "'>" + _TabFilter + "</Value></Eq></Where>" + tmp; } tquery.Query = tmp; SPListItemCollection item = list.GetItems(tquery); if (item.Count != 0) { GridView1.DataSource = item.GetDataTable(); GridView1.DataBind(); } else { lblError.Text = "No Items found"; lblError.Visible = true; } } catch (Exception ex) { lblError.Text = "An error occurred:" + ex.ToString(); lblError.Visible = true; } } } }); } catch (Exception ex) { lblError.Text = "An error occurred:" + ex.ToString(); lblError.Visible = true; } }
protected override void RenderFieldForInput(HtmlTextWriter writer) { var field = (SPFieldLookup)Field; if (!field.AllowMultipleValues) { throw new NotSupportedException(); } var list = Web.Lists[new Guid(field.LookupList)]; var whereCondition = WhereCondition; if (string.IsNullOrEmpty(whereCondition)) { whereCondition = string.Format("<Where></Where><OrderBy><FieldRef Name='{0}' /></OrderBy>", field.LookupField); } var query = new SPQuery { Query = whereCondition }; var items = list.GetItems(query); var rows = Math.Ceiling((double)items.Count / Columns); if (!Height.IsEmpty) { writer.AddStyleAttribute(HtmlTextWriterStyle.Height, Height.ToString()); writer.AddStyleAttribute(HtmlTextWriterStyle.OverflowY, "auto"); } writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.RenderBeginTag(HtmlTextWriterTag.Table); var index = 0; for (var i = 1; i <= rows; i++) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); for (var j = 1; j <= Columns; j++) { writer.RenderBeginTag(HtmlTextWriterTag.Td); if (index < items.Count) { var item = items[index]; writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID + "_" + index); writer.AddAttribute(HtmlTextWriterAttribute.Type, "checkbox"); writer.AddAttribute(HtmlTextWriterAttribute.Value, item.ID.ToString()); writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID); if (SelectedItems.Contains(item.ID)) { writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked"); } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); writer.AddAttribute(HtmlTextWriterAttribute.For, ClientID + "_" + index); writer.RenderBeginTag(HtmlTextWriterTag.Label); writer.Write(SPEncode.HtmlEncode(item[field.LookupField].ToString())); writer.RenderEndTag(); } else { writer.Write(" "); } writer.RenderEndTag(); // td index++; } writer.RenderEndTag(); } writer.RenderEndTag(); // table writer.RenderEndTag(); // div RenderValidationMessage(writer); }
/// <summary> /// Writes the debug. /// </summary> /// <param name="writer">The writer.</param> /// <param name="title">The title.</param> /// <param name="message">The message.</param> private void WriteDebug(TextWriter writer, string title, string message) { writer.Write("<font color=red>" + title + "</font><br><font color=blue>"); writer.Write("<pre>" + SPEncode.HtmlEncode(message) + "</pre>"); writer.Write("</font><br>"); }
private bool CheckIfExists(string uncheckedUrl, Uri url) { bool exits = false; SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(url.OriginalString)) { SPWeb web = site.OpenWeb(); if (web.Exists) { SPFile file = null; SPFolder folder = null; SPList list = null; welcomepage = uncheckedUrl; if (web.ServerRelativeUrl == welcomepage) { exits = true; isweb = true; } try { if (web.IsRootWeb) { if (uncheckedUrl != "/") { if (uncheckedUrl.StartsWith(web.ServerRelativeUrl) && web.ServerRelativeUrl != "/") { file = web.GetFile(web.RootFolder.WelcomePage); try { exits = file.Exists; issubcollection = true; isweb = true; } catch (Exception ex) { ex.ToString(); exits = false; isweb = true; issubcollection = true; } } else { try { file = web.GetFile(uncheckedUrl); exits = file.Exists; isweb = !exits; } catch (Exception ex) { ex.ToString(); exits = false; isweb = !exits; } } } else { if (web.RootFolder.WelcomePage.Trim().Length > 0) { file = web.GetFile(web.RootFolder.WelcomePage); } } } else { issubcollection = true; string wurl = web.ServerRelativeUrl.TrimStart(new char[] { '/' }); wurl = uncheckedUrl.Replace(wurl, string.Empty); wurl = wurl.TrimStart(new char[] { '/' }); if (!string.IsNullOrEmpty(wurl)) { file = web.GetFile(wurl); } } } catch (Exception ex) { ex.ToString(); exits = false; } if ((file == null || !file.Exists) && exits == false) { if (url.AbsolutePath.Equals("/")) { folder = web.RootFolder; welcomepage = folder.WelcomePage; exits = true; } else { try { list = web.GetList(uncheckedUrl); } catch (Exception ex) { ex.ToString(); } if (list != null) { SPListItem item = web.GetListItem(uncheckedUrl); if (item != null && item.File != null && item.File.Exists) { exits = true; welcomepage = uncheckedUrl; } else { islist = true; if (item != null && item.ContentTypeId.IsChildOf(SPBuiltInContentTypeId.Folder)) { islist = true; exits = true; //?RootFolder=%2FProducts%2FSubFolder folder = web.GetFolder(item.UniqueId); welcomepage = folder.DocumentLibrary.DefaultViewUrl + "?RootFolder=" + SPEncode.HtmlEncode(folder.Url); } else { if (uncheckedUrl.ToLowerInvariant().EndsWith(list.Title.ToLowerInvariant()) || uncheckedUrl.ToLowerInvariant().EndsWith(list.Title.ToLowerInvariant() + "/")) { exits = true; welcomepage = list.DefaultViewUrl; } else { if (uncheckedUrl.Contains("Forms")) { exits = false; foreach (SPView view in list.Views) { if ("/" + view.Url == uncheckedUrl) { exits = true; break; } } foreach (SPForm form in list.Forms) { if ("/" + form.Url == uncheckedUrl) { exits = true; break; } } if (exits) { welcomepage = url.PathAndQuery; } } else { exits = false; welcomepage = uncheckedUrl; } } } } } else { //TODO _layouts afhandelen if (uncheckedUrl.ToLower().Contains("_layouts") || uncheckedUrl.ToLower().Contains("_login") || url.OriginalString.ToLower().Contains("_windows") || url.OriginalString.ToLower().Contains("_forms") || url.OriginalString.ToLower().Contains("_trust")) { exits = true; welcomepage = url.PathAndQuery; } else { if (uncheckedUrl.Contains(".aspx") && uncheckedUrl.EndsWith("/")) { uncheckedUrl = uncheckedUrl + "/"; exits = true; welcomepage = uncheckedUrl; } } /* * try * { * folder = web.GetFolder(url.AbsoluteUri);// .RootFolder; * } * catch (Exception ex) { ex.ToString(); } * * if (folder != null) * { * try * { * file = folder.Files[url.AbsoluteUri]; * } * catch (Exception ex) { ex.ToString(); } * * if (file != null && file.Exists) * { * welcomepage = file.Url; * exits = true; * } * else * { * exits = false; * if (web.Exists && list != null && !file.Exists) * { * exits = false; * } * * //else * //{ * // welcomepage = uncheckedUrl; * // exits = true; * //} * * } * } * else * { * welcomepage = uncheckedUrl; * exits = false; * } */ welcomepage.ToString(); } } } else { if (file != null) { exits = true; isweb = false; if (issubcollection) { welcomepage = file.ServerRelativeUrl; } else { welcomepage = file.Url; } } } } /* * if (!string.IsNullOrEmpty(welcomepage)) * { * exits = true; * //welcomepage = "Default.aspx"; * } */ } }); return(exits); }