Archive

Archive for August, 2010

Infopath sample code


public void FormEvents_Loading(object sender, LoadingEventArgs e)
{

// Get field 1
XPathNavigator field1 = this.MainDataSource.CreateNavigator().SelectSingleNode(“/my:myFields/my:field1”, NamespaceManager);

// Get field 2
XPathNavigator field2 = this.MainDataSource.CreateNavigator().SelectSingleNode(“/my:myFields/my:field2”, NamespaceManager);
// Copy value from one field to another.
field2.SetValue(field1.Value);

}

Advertisements
Categories: Uncategorized

MSBUILD K2

Categories: Uncategorized Tags:

MOSS 2007 Feature code


namespace Project.Sharepoint.UI.FeatureReceiver

Class Microsoft.SharePoint.SPFeatureReceiver

Methods:
———
public override void FeatureInstalled(SPFeatureReceiverProperties properties)

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPWeb web = (SPWeb)properties.Feature.Parent;
SPSite site = web.Site;
if (site.Features[new Guid(“3FF0B58E-B2D1-461f-9E50-F9A2E8EA13A1”)] != null)
{
if (web.WebTemplate.Equals(“BLANKINTERNET”) ||
web.WebTemplate.Equals(“CMSPUBLISHING”) ||
web.WebTemplate.Equals(“SPSNHOME”) ||
web.WebTemplate.Equals(“SPSREPORTCENTER”) ||
web.WebTemplate.Equals(“SPSNEWS”) ||
web.WebTemplate.Equals(“WIKI”)
)
{
web.Features.Add(new Guid(“B5792BF4-3B93-4b98-A64C-27981E98471C”));
web.Update();
//publishing
}
else if (web.WebTemplate.Equals(“SPSMSITEHOST”) || web.WebTemplate.Equals(“SPSPERS”))
{
web.Features.Add(new Guid(“8F7A6610-F649-4d14-A6C3-BF296ACDD36D”));
web.Update();
}
else
{
web.Features.Add(new Guid(“811B39AF-9BF1-45ce-8B8F-78C7F5CF151B”));
web.Update();
//team
}
try
{
web.Features.Add(new Guid(“A149DB93-9897-4ffb-B083-663E6AF77A8A”));
}
catch (Exception ex)
{

}

}
});
}

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)

public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
————————————————————————————————
CustomList
==========

public class CustomList : SPFeatureReceiver
{
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{

}

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
using (SPSite site = properties.Feature.Parent as SPSite)
{
SPWeb currentWeb = null;
//Guid gRootWebId = Guid.Empty;
if (site != null)
{
currentWeb = site.RootWeb;
//gRootWebId = currentWeb.ID;
}
else
{
currentWeb = properties.Feature.Parent as SPWeb;
//gRootWebId = currentWeb.Site.RootWeb.ID;
}

attemptListDelete(currentWeb, “Stylesheets”);
}

}

public override void FeatureInstalled(SPFeatureReceiverProperties properties)
{

}

public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
{

}

private void attemptListDelete(SPWeb web, string sListUrl)
{
SPList list = null;
try
{
//Cnginf from this:
//list = web.GetList(sListUrl);
//to this because GetList method requieres the server relative url from the list

list = web.Lists[sListUrl];
}
catch (ArgumentException argExc)
{ }
if (list != null)
{
try
{
list.Delete();
}
catch (SPException SpExc)
{ }
}
}
}

feature.xml
—————

====================================
LeftNavigationLink
———————
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Navigation;

namespace TCS.Sharepoint.UI.FeatureReceiver
{
public class LeftNavigationLink : SPFeatureReceiver
{
int menuItemID;

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPSite site = properties.Feature.Parent as SPSite)
{
SPWeb quickLaunchWeb = site.RootWeb;

SPNavigationNodeCollection quickLaunchNodes = quickLaunchWeb.Navigation.QuickLaunch;

SPNavigationNode TCSMenuItem = new SPNavigationNode(“TCS Global”, “http://TCS.com”, true);

quickLaunchNodes.AddAsLast(TCSMenuItem);

quickLaunchWeb.Update();

menuItemID = TCSMenuItem.Id;

site.RootWeb.Properties.Add(“TCSLink”, menuItemID.ToString());
site.RootWeb.Properties.Update();
}
}

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
using (SPSite site = properties.Feature.Parent as SPSite)
{
SPWeb quickLaunchWeb = site.RootWeb;

SPNavigationNodeCollection quickLaunchNodes = quickLaunchWeb.Navigation.QuickLaunch;

menuItemID = int.Parse(site.RootWeb.Properties[“TCSLink”].ToString());

SPNavigationNode TCSMenuItem = quickLaunchNodes.Navigation.GetNodeById(menuItemID);

quickLaunchNodes.Delete(TCSMenuItem);

quickLaunchWeb.Update();

site.RootWeb.Properties.Remove(“TCSLink”);
site.RootWeb.Properties.Update();
}
}

public override void FeatureInstalled(SPFeatureReceiverProperties properties)
{

}

public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
{

}
}
}

Categories: Uncategorized

Access Infopath In web

Categories: Uncategorized

Kerberos- NTLM

Categories: Uncategorized

Enabling-forms-authentication-in-moss

Categories: Uncategorized

WPF

Categories: Uncategorized