Friday, 29 June 2012


SharePoint 2010: error "The administration service is running sl all administration jobs will be run in the timer service"

Symptom:
I had a solution that was stuck in the deploying state. When I looked at it, it had only deployed successfully on one the the front ends. To solve the problem, I ran stsadm execadmjobs. I have done this multiple times in 2010, but this time I got this message:
The administration service is running so all administration jobs will be run in the timer service.
Problem:
The timer service is set to take care of all admin tasks, so it is telling you that the jobs will run when the timer service is good and ready to kick them off, but until then, just sit on your hands and wait.
Solution:
Stop the admin service, then run the command to execute the admin jobs, then turn back on the admin service. These are the three powershell commands to do this:
  • net stop SPAdminV4
  • Start-SPAdminJob
  • net start SPAdminV4
The first command shuts off the admin service. The second command is the powershell equivalent to stsadm execadmjobs and the third one turns back on the admin service. 

Thursday, 7 June 2012

Page Title disappears after Ajax Post back


Page Title disappears after Ajax Post back

The Problem:
SharePoint page titles disappears when Ajax postback, title turn to square icons or empty space instead of page title.

We are having custom form and are using ajax to save the postback but when page postback asysnc the page title turns to square.
We have update panel as well in the webpart

Solution :

This was the line in master page after master page design:

<title id=”onetidTitle”>
<asp:ContentPlaceHolder id=”PlaceHolderPageTitle” runat=”server”/>
</title>


After figuring out i found that if i removed the space between the html tag then problem get resolved and title appears as it required.

The correct line of code is as follows :

<title id=”onetidTitle”><asp:ContentPlaceHolder id=”PlaceHolderPageTitle” runat=”server”/></title>

Sharepoint 2010 : CreateSubSiteGroup


Sharepoint 2010 : CreateSubSiteGroup       


         /// <summary>
        /// Create group
        /// </summary>
        public void CreateSubSiteGroup(SPWeb web, string groupName, string PermissionLevel, string groupDescription, SPFieldUserValueCollection fieldUserNames)
        {
            SPUserCollection users = web.AllUsers;
            SPUser owner = web.SiteAdministrators[0];
            SPMember member = web.SiteAdministrators[0];
            SPGroupCollection groups = web.SiteGroups;
            web.BreakRoleInheritance(true);
            groups.Add(groupName, member, owner, groupDescription);
            SPGroup newSPGroup = groups[groupName];
            SPRoleDefinition role = web.RoleDefinitions[PermissionLevel];
            SPRoleAssignment roleAssignment = new SPRoleAssignment(newSPGroup);
            roleAssignment.RoleDefinitionBindings.Add(role);
            web.RoleAssignments.Add(roleAssignment);
            AddUsersToSpecifiedGroup(fieldUserNames, web, newSPGroup);
            web.Update();
        }

Sharepoint 2010 Programatically - Check if web availability


Check if the site already exists,if yes redirect to error page      

      /// <summary>
        /// Check if the site already exists,if yes redirect to error page
        /// </summary>
        /// <param name="siteTitle"></param>
        /// <param name="siteCollectionUrl"></param>
        /// <returns></returns>
        public bool isSiteAvailability(string siteTitle, string siteCollectionUrl)
        {
            bool retrunValue = false;
            try
            {
                SPSite site = new SPSite(siteCollectionUrl);
                SPWebCollection web = site.AllWebs;
                for (int siteCount = 0; siteCount < site.AllWebs.Count; siteCount++)
                {
                    if (site.AllWebs[siteCount].Name.Trim() == siteTitle.Trim())
                    { retrunValue = true; break; }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return retrunValue;
        }

Get SPFieldUserValueCollection for given users


Get SPFieldUserValueCollection 

Pass the string of users(), and return them as SPFieldUserValueCollection

        /// <summary>
        /// Get the users and return the collection of users
        /// </summary>
        /// <param name="web"></param>
        /// <param name="users"></param>
        /// <returns></returns>
        public SPFieldUserValueCollection GetSPFieldUserValueCollection(SPWeb web, string users)
        {
            SPFieldUserValueCollection userValue = new SPFieldUserValueCollection(web, users);
            return userValue;
        }

Migration - Managed Path Issue


Migration - Managed Path Issue
  • When we restore the site collection make sure that the managed path is same
  • If not,then the managed path of the new site collection will be replaced by the managed path of the restored site collection


I came across this situation when i migrated the site from sharepoint 2007 to sharepoint 2010


Content database Migration Method:
When we migrate the sites from WSS 3.0 or sharepoint 2007 to Sharepoint 2010,there is will be issue in site collection managed path