Thursday, September 16, 2010

Jquery is not working with the combination of UpdatePanel

I am using the Jquery get some effects for elements. The added Jquery code for element is not working because it is placed inside the update panel.
Inorder to run the Jquery in the Update panel we need to write the below code

var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_endRequest(function() { // re-bind your jquery events here

});

Hope this will help you.

Wednesday, July 14, 2010

SharePoint WebPart life cycle

Life Cycle of sharepoint Webparts:


1. Protected override void OnInit(EventArgs e)


OnInit – Configuration values set using WebBrowsable properties and those in web part task pane are loaded into the web part.


2. Protected override void OnLoad(EventArgs e)


OnLoad

User Generated Event – for e.g. button click on the web part.


3. Protected override void CreateChildControls()


CreateChildControls – All the controls specified are created and added to controls collection. When the page is being rendered for the first time the method generally occurs after the OnLoad() event. In case of postback, it is called before the OnLoad() event. We can make use of EnsureChildControls() - It checks to see if the CreateChildControls method has yet been called, and if it has not, calls it.


4. Protected override void LoadViewState(object savedState) //Only at Postback


LoadViewState – The view state of the web part is populated over here.


5. protected override void OnPreRender(EventArgs e)


OnPreRenderHere we can change any of the web part properties before the control output is

drawn.


6. protected override void Render(System.Web.UI.HtmlTextWriter writer)


RenderContents – Html Output is generated.


7. protected override void OnUnload(EventArgs e)
8. public override void Dispose()

Friday, March 19, 2010

C# Programmatically Set audiance permissions for Sharpoint Quick launch bar

To add the links in the left navigation first we need to get all links in the quick launch bar using SPNavigationCollection class

SPWeb web = SPContext.Current.Web;
SPNavigationCollection coll = web.Navigation.QuickLaunch;

/* With SPNavigationNode class we are adding our custom links(Node) in the quick launch bar */

SPNavigationNode node = new SPNavigation(linkTitle,url,true);
/*Add the node as root in the quick launch bar*/
web.AllowUnSafeUpdates = true;
coll.AddAsFirst(node);
/*Give permissions to the link*/
node.Properties.Add("Audiance",";;;;","groupName or UserName");
node.Update();

/* Creating sub links under main links in quick launch bar */
SPNavigation subnode = new SPNavigation(linkSubTitle, subUrl,true);
node.Children.AddAsLast(subNode);
/* Providing permssions to sub links in quick launch */
subNode.Properties.Add("Audiance",";;;;","group or username");
subNode.Update();
web.AllowUnSafeUpdates = false;

thats all !!!!

Thursday, February 25, 2010

C# Copy the Permissions from one list to another list in SharePoint

Today I have got a requirement to copy the permission from existing list and Create a new list with the permissions inherited from existing list programmatically.

Here is code which is very simple will make you better understanding .

using (SPSite spSite = new SPSite("http://servername:Portnumber/"))
{
using (SPWeb spWeb = spSite.OpenWeb())
{
SPList spList = spWeb.Lists["AgeRating"];

//Get all roles from the existing list
SPRoleAssignmentCollection coll = spList.RoleAssignments;

SPListCollection lists = spWeb.Lists;

// create new Generic list called "MyList"

if (!spWeb.Lists.Cast().Any(list => string.Equals(list.Title, "MyList")))
{
spWeb.AllowUnsafeUpdates = true;
lists.Add("MyList", "My list Description", SPListTemplateType.GenericList);
spWeb.AllowUnsafeUpdates = false;
}

SPList targetList = spWeb.Lists["MyList"];
foreach (SPRoleAssignment role in coll)
{
targetList.BreakRoleInheritance(false);
spWeb.AllowUnsafeUpdates = true;
targetList.RoleAssignments.Add(role);
}

spWeb.AllowUnsafeUpdates = false;
}
}

Thursday, February 4, 2010

Install Windows media player in Windows Server 2008 R2 server

If your Windows server 2008 r2 operating system didn't find the Windows media player installed. Please follow the below steps how to add the feature

1)Go to Start --> Administration tools --> server manger

2)Click features --> click on Add Features --> Select the "Desktop Experience"



3)Complete the wizard and restart the PC.

Looks cool right...

Tuesday, December 8, 2009

Migration SharePoint 2007 to SharePoint 2010

Prerequisites for migrating SharePoint 2007 site to SharePoint 2010:1. Check whether the packages (wsp features etc) in source server are same as in the target server (if not please install).
2. Check the web.config modifications made in the MOSS 2007 site (source site), if any do the same modifications on MOSS 2010 site (target site) accordingly.

Migration process:

The only process to migrate the site from SharePoint 2007 to SharePoint 2010 is the migrating contentDB of source site to target site.

Steps to follow for migrating ContentDB:

1. Take the backup of the source site contentDB and restore the same on target server.
2. Create the web application in SharePoint 2010, and then create the site collection (it doesn’t matter what site template you are using for creating site collection).
3. Once finished creating the SharePoint 2010 site, go to central administration --> Manage content databases --> select the web application you created for migration --> click on database --> check in the remove content database --> click ok

4.Add the restored database in the target site by using stsadm.exe in command prompt

Stsadm.exe –o addcontentdb –url “enter your url” –databasename “enter your db name”

5.Restart iis.

Monday, December 7, 2009

Hide the infopath form banner "Powered by infopath form services"

After the publishing the infopath form in the SharePoint Site. You will find a banner called "Powered by infopath form services" in at the bottom of infopath form.

Blow command explains how to customize the form banner-

Remove banner:
stsadm.exe -o setformserviceproperty -pn allowbranding -pv false

Add banner:
stsadm.exe -o setformserviceproperty -pn allowbranding -pv true

To check the weather the banner is set or not
stsadm.exe -o getformserviceproperty -pn allowbranding


hope this helps you very much.