Rechercher dans ce blog

mercredi 16 juin 2010

Passage des valeurs de propriétés d'un Web part SharePoint vers un UserControl

on suppose que nous avons un Control utilisateur "CustomUC" que nous allons charger dans un Web part SharePoint et que ce Control utilisateur nécessite des valeurs de configuration du Web part :

public class CustomWebPart : System.Web.UI.WebControls.WebParts.WebPart
{

bool prop1=true;

[WebBrowsable(true), Personalizable(PersonalizationScope.Shared), WebDescription("prop1"), Category("Config"), WebDisplayName("prop1 visible")]
public bool Prop1
{
get { return prop1; }
set { prop1= value; }
}

bool prop2= true;

[WebBrowsable(true), Personalizable(PersonalizationScope.Shared), WebDescription("prop2
"), Category("Config"), WebDisplayName("prop2")]
public bool Prop2
{
get { return prop2; }
set { prop2= value; }
}


public CustomWebPart()
{
this.ChromeType = PartChromeType.None;
}

protected override void CreateChildControls()
{
base.CreateChildControls();
CustomUC control = (CustomUC )Page.LoadControl("~/_controltemplates/CustomUC .ascx");
control.Prop2= this.Prop2;
control.Prop1= this.Prop1;
this.Controls.Add(control);
}
}

Problème de post Back en utilisant le Response.end()

lors d'un évènement sur un bouton dans une page web sous SharePoint faisant appel a Reponse.flush() et Response.end(), il arrive que parfois tout les évènements dans la page et les bouton ne répond plus.

Pour ce faire, il faut soumettre la page dans au moins un bouton dans la page tel que :

OnClientClick="this.form.onsubmit = function() {return true;}"

ajouter ce code au niveau de la propriété "OnClientClick" du bouton.

Ajouter du code Javascript au Custom Action

Id="CustomId"
GroupId="SiteActions"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="2000"
Title="exemple de Custom Action avec JavaScript"
ImageUrl="~/site/_layouts/Images/file-manager.png"
Description="Description" >
javascript: if (confirm(' Do you want to archive all ?')) { window.location.href='{SiteUrl}/_layouts/page.aspx' } else { void('') };"
/>

Téléchargement d'un document a partir d'une bibliothèque SharePoint


SPFile filedownload = SPContext.Current.Web.GetFile(chemin complet du fichier);
byte[] fileByte = filedownload.OpenBinary();
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment;filename=" + filedownload.Name);
Response.ContentType = "application/pdf";
Response.BinaryWrite(fileByte);
Response.Flush();
Response.End();

vendredi 6 novembre 2009

Adding new Link to navigation Bar in mySite Sharepoint

  1. At first go to Central Administration Sharepoint
  2. Select your shared services Administration
  3. Select Personnalization Site links

  4. and finally add your link Url and owner





Removing sharepoint webparts from pages

SPFile thePage = web.RootFolder.Files["default.aspx"];

SPLimitedWebPartManager manager = thePage.GetLimitedWebPartManager(PersonalizationScope.Shared);
ListWebPart> webParts = new ListWebPart>();

foreach (Microsoft.SharePoint.WebPartPages.WebPart webPart in manager.WebParts)
{
webParts.Add(webPart);
}

foreach (Microsoft.SharePoint.WebPartPages.WebPart webPart in webParts)
{
manager.DeleteWebPart(webPart);
manager.Web.Update();
}

manager.Dispose();
web.Update();
web.Close();