Rajkamal's Blog
My Solutions in SharePoint,ASP.NET, Sql server, Visual Studio, C#, Java script, CSS and more.
Tuesday, December 21, 2010
Sunday, December 19, 2010
Create a sharepoint feature for deploying Pages in Page library
Element.XML: (define which pages which needs to copy into page library)
Name: Name of the module where you define the page to copy to the site in Share point mode.
URL: Listing the Document Library where the pages will be added and updated.
RootWebOnly: this property has as its limit the copies of the root page of the Site in SharePoint.
Path: Feature Folder where the page to pass the copy to the Share Point Site.
Scope: The scope defines the context in which the Feature can be activated or deactivated. Setting the scope equal to Web means that the Feature can be activated or deactivated within the context of the site. A setting of Site means that the Feature can be activated or deactivated within the scope of a site collection.
Note: There are also WebApplication and Farm values.
Hope this helps you...
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...