My Solutions in SharePoint,ASP.NET, Sql server, Visual Studio, C#, Java script, CSS and more.
Thursday, September 16, 2010
Jquery is not working with the combination of UpdatePanel
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)
OnPreRender – Here 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
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
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
{
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
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
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"
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.