Search This Blog

Total Pageviews

Friday, September 30, 2011

Change the Display name for FBA Users


i:0#.f|mName|accountname
mName = membershipprovideraliasinCentralAdmin
accountname = account in Active Directory
  1. You would need to run a PowerShell command for the –Web parameter being the SiteCollection URL.
  2. You would need to login to that Site Collection at least once for the script to update the Display Name. This is something like alerts on a site will work for the user if we would have logged into that site collection at least once.
Set-SPUser “i:0#.f|mName|accountname” -Web http://sp2010/ -DisplayName "User Name"

Check the SharePoint Permission level through Javascript


if(HasRights(0x0, 0x80))
{
    alert("You have rights to delete versions.");
}
A full list of the permissions masks can be found here.

also some other references :

http://atulchhoda.wordpress.com/2009/01/27/corejs-disable-ecb-menu-items-for-oob-application-pages-based-on-permissions-%E2%80%A6mystery-solved%E2%80%A6/

Tuesday, September 27, 2011

Apply CSS in .Net Menu Control


<asp:menu id="NavigationMenu1" CssClass="menu1"
  staticdisplaylevels="3"
  staticsubmenuindent="0" 
  orientation="Vertical"
  target="_blank"
  Font-names="Arial, Gill Sans"
  Width="100px"
  runat="server">

  <LevelMenuItemStyles>
    <asp:MenuItemStyle CssClass="level1"/>
    <asp:MenuItemStyle CssClass="level2"/>
    <asp:MenuItemStyle CssClass="level3" />
    <asp:MenuItemStyle CssClass="level4" />
  </LevelMenuItemStyles>
  
  <StaticHoverStyle CssClass="hoverstyle"/>
  
  <items>
    <asp:menuitem text="Home" tooltip="Home">
    <asp:menuitem text="Section 1" tooltip="Section 1">
      <asp:menuitem text="Item 1" tooltip="Item 1"/>
      <asp:menuitem text="Item 2" tooltip="Item 2"/>
      <asp:menuitem text="Item 3" tooltip="Item 3"/>
    </asp:menuitem>
    <asp:menuitem text="Section 2" tooltip="Section 2">
      <asp:menuitem text="Item 1" tooltip="Item 1"/>
      <asp:menuitem text="Item 2" tooltip="Item 2">
        <asp:menuitem text="Subitem 1"/>
        <asp:menuitem text="Subitem 2" />
      </asp:menuitem>
      <asp:menuitem text="Item 3" tooltip="Item 3"/>
    </asp:menuitem>
  </asp:menuitem>
  </items>
</asp:menu>

.level1
{
    color: White;
    background-color: Black;
    font-variant: small-caps;
    font-size: large;
    font-weight: bold;
}

.level2
{
    color: Blue;
    font-family: Gill Sans MT !important;
    font-size: medium;
    background-color: Gray;
}

.level3
{
    color: black;
    background-color: Silver;
    font-family: Gill Sans MT !important;
    font-size: small;
}

.hoverstyle
{
    font-weight: bold;
}

.level4
{
    background-color: Gray !important;
    color: White !important;
    font-size: small;
}   

SharePoint Calendar overlay

Displaying Default Resources on the Group Calendar

Monday, September 26, 2011

Regular Expression Validation Custom Field Type

Edit / Display form Url


// Edit form full url
string.Format("{0}{1}?ID={2}", item.Web.Url, item.ParentList.Forms[PAGETYPE.PAGE_EDITFORM].ServerRelativeUrl, item.ID);

// Edit form relative url
string.Format("{0}?ID={1}", item.ParentList.Forms[PAGETYPE.PAGE_EDITFORM].ServerRelativeUrl, item.ID);


// Display form full url
string.Format("{0}{1}?ID={2}", item.Web.Url, item.ParentList.Forms[PAGETYPE.PAGE_DISPLAYFORMServerRelativeUrl, item.ID);

// Display form relative url
string.Format("{0}?ID={1}", item.ParentList.Forms[PAGETYPE.PAGE_DISPLAYFORM].ServerRelativeUrl, item.ID);

With Managed Metadata You have a Choice

Sharepoint Fields and update / retrive Values



Lookup Field

Field Class: SPFieldLookup
Field Value Class: SPFieldLookupValue

Populating Information:

item["FieldName"] = new SPFieldLookupValue("Title"); // SharePoint will do the lookup as long as the LookupValue's are unique
item.Update();
or
item["FieldName"] = new SPFieldLookupValue(1, "Title");
item.Update();

Retrieving Information:

SPFieldLookupValue itemValue = item["FieldName"] as SPFieldLookupValue;
int id = itemValue.LookupId;
string value = itemValue.LookupValue;
Multiple Lookup Field

Field Class: SPFieldLookup
Field Value Class: SPFieldLookupValueCollection

Populating Information:

SPFieldLookupValueCollection itemValues = SPFieldLookupValueCollection();
itemValues.Add(new SPFieldLookupValue(1, "Title"));
item["FieldName"] = itemValues;
item.Update();

Retrieving Information:

SPFieldLookupValueCollection itemValues = item["FieldName"] as SPFieldLookupValueCollection;
foreach (SPFieldLookupValue itemValue in itemValues)
{
   int id = itemValue.LookupId;
   string value = itemValue.LookupValue;
}
User Field

Field Class: SPFieldUser
Field Value Class: SPFieldUserValue

Populating Information:

web.EnsureUser(@"domain\username");
SPUser user = web.AllUsers[@"domain\username"];
item["FieldName"] = user;
item.Update();

Retrieving Information:

string currentValue = item["FieldName"].ToString();
SPFieldUser userField = list.Fields.GetFieldByInternalName("FieldName");
SPFieldUserValue itemValue = (SPFieldUserValue)userField.GetFieldValue(currentValue);
SPUser user = itemValue.User;
URL Field

Field Class: SPFieldUrl
Field Value Class: SPFieldUrlValue

Populating Information:

SPFieldUrlValue urlValue = new SPFieldUrlValue();
urlValue.Url = "http://www.google.com";
urlValue.Description = "Google";
item["FieldName"] = urlValue;
item.Update();

Retrieving Information:

SPFieldUrlValue urlValue = new SPFieldUrlValue(item["FieldName"].ToString());
string url = urlValue.Url;
string description = urlValue.Description;
Multiple Choice Field

Field Class: SPFieldMultiChoice
Field Value Class: SPFieldMultiChoiceValue

Populating Information:

SPFieldMultiChoiceValue itemValue = new SPFieldMultiChoiceValue();
itemValue.Add("Choice 1");
itemValue.Add("Choice 2");
itemValue.Add("Choice 3");
item["FieldName"] = itemValue;
item.Update();

Retrieving Information:

SPFieldMultiChoiceValue itemValue = new SPFieldMultiChoiceValue(item["FieldName"].ToString());
foreach (string choice in itemValue)
{
   // value is in choice
}

Saturday, September 24, 2011

Cross site List Roll up webpart

My Task List Roll up

SharePoint 2010 Visual How Tos by Microsoft