Posts

Showing posts from August, 2012

Programmatically generate/update data for an InfoPath Form and save it in a SharePoint Form Library

Steps  1) Create an Infopath form using the Microsoft InfoPath desinger. and publish the infoPath form into respective form library. I also created an empty form in the form library based on this template (BLANK.xml). This example opens an empty form (BLANK.xml) from the form library, reads it into an xml document, parses the xml document to update the fields, and then saves the xml document as a new file back to the form library. 2) // opens the site SPWeb webSite = new SPSite(txtUrl.Text).OpenWeb(); // gets the blank file to copy SPFile BLANK = webSite.Folders["Test1"].Files["BLANK.xml"]; // reads the blank file into an xml document MemoryStream inStream = new MemoryStream(BLANK.OpenBinary()); XmlTextReader reader = new XmlTextReader(inStream); XmlDocument xd = new XmlDocument(); xd.Load(reader); reader.Close(); inStream.Close(); //gets the root element from the xml document XmlElement root = xd.DocumentElement; //the loop counter is started at 2 to skip

Show/hide Two WebParts based on usergroups in Landing page

Image
1) Create custom Document Library (ex: Pages) break the permissions and assign NT authenticated Users as read permissions 2) Create Web Part Page on SharePoint site 2)       Give proper name for Landing Page(ex: Default.aspx) and select the "Pages" from Document Library dropdown 3) Add 2 Content Editor WebParts on created page 4) Assign the groups to First Content Editor WebPart as Taget Audience 5) In content Editor HTML source, add the id to DIV tag (ex: <div id=" authenticatedContent "> we need to use this id in second content editor webpart script file for verifying length) 6) Open the Second Content Editor WebPart HTML Source and add the below script <div id="noaccessmsg"></div> <script language="javascript" src="/root/root/SiteAssets/js/jquery-1.7.2.min.js"></script><script type="text/javascript"> if ($("#authenticatedContent").length == 0){              

How to Configure Form Based Authentication (FBA) in SharePoint 2010

Image
I found good article(step by step) on Internet and posting here ........enjoy :) Introduction This article explains step by step information on configuring Form Based Authentication (FBA) in SharePoint 2010. This article would be useful for developers/designers/architects and those who want to implement form based authentication (FBA) for their SharePoint 2010 sites as a business requirement. We cannot use the classic / basic claimed based authentication for all business scenarios. I was recently working on a consumer portal or product selling site where form based authentication is most appropriate. This article resolves authentication issues by configuring a SharePoint 2010 site with form based authentication. Difference between MOSS 2007 and SharePoint 2010 There is no huge difference in configuring FBA for a MOSS 2007 site and a SharePoint 2010 site. You cannot implement FBA for a SharePoint 2010 class authentication site. FBA can be implemented only for a claims authentica

BeforeProperties/AfterProperties in Event Receivers

As many of you know, event receivers are a great way to hook into various SharePoint events.  These can apply to Feature events such as FeatureActivated, List events such as FieldAdded, and many others.  The most common set of receivers used, however, are part of SPItemEventReceiver which let you wire your code up to a number of events that can occur to items on a list or library. When working with events, you’ll quickly find that before (synchronous) and after (asynchronous) events exist, and the method suffix such as “ing” (e.g. ItemAdding) and “ed” (e.g. ItemAdded) will tell you whether it gets invoked before or after the actual change is made.  Basic stuff. And, as you get deeper, you’ll even find that you can extract the before and after state of the change.  For example, you can hook into the ItemUpdating event for a document library and prevent a user from changing a certain column.  The code might look like this: public override void ItemUpdating(SPItemEventProperties