25 November 2010

WSP Process stuck in "Deploying"

Recently, I deployed my Webpart solution packages created in sharepoint Farm.
After a long waiting i still figured the solution getting "Deploying" as its status..
Initially i Tried

stsadm -o execadmsvcjobs on the server running Central Admin.  No change. 
Since it was a farm deployment i Thought improper deployment was performed.

so I reset the IIS to get a refreshed processes running but still no effect.

Solution: Not Sure if its correct but worked for me.I opened list of timer jobs (Operations > Timer Job Definitions) search the job which point to the WSP solution we are deploying..Killing the Process will do the Trick.

However this does not actually deploy but only status is populated as "Deployed".
To Overcome this solution since you are on Farm Servers you need to Execute stsadm -o execadmsvcjobs on all the servers

23 November 2010

SharePoint 2010 Database Naming Standards


Database Naming conventions for SharePoint 2010 well defined by John W Powell -Click Here to view!


15 November 2010

FBA : Change Password

From my Earlier blog stating Form Based Authentication in SharePoint (MOSS 2007).
 ( Click Here )

Many were interested in password management for the users. A complete package ready to use is uploaded on codeplex.
However here I’m attaching a custom strip down to users change Password code snippet for the same.

There are two options while password management
1. Just to change Password
2. to provide Question & Answer along with Password change
Note : for Option (2) please add/updated web.Config file within Membership provider

///save button functionlity
void btnChangePassword_Click(object sender, EventArgs e)
if (Validate(true))
string AppName = Membership.ApplicationName;
if (.Text.Trim().ToString() != .Text.Trim().ToString())
{ .Text = " New and Confirm password Mismatch ! " ; }
if (Membership.Provider.ChangePassword(.Text, .Text, .Text))
{ //membership provider has Change Password checked in Web.Config
if (Membership.Provider.ChangePasswordQuestionAndAnswer(.Text, .Text, .Text, .Text))
//Message: " Your Password Has Been Sucessfully Changed.."
catch (MembershipPasswordException ee)
{//Exception Message}


Let me know your comments/ exceptions etc.
Will be glad to get back to you.

Active Directory: Password Management using SharePoint Webpart.

For Active Directory member the password management is one of the vital functionality which developer needs to add in his efforts to provide a appropriate solution.
Here below is the code snipplet to achieve this functionality.

I have implemented using SharePoint Webpart.

please specify you validation accordingly.
-:Core Code:-

WindowsImpersonationContext aspContext = null;
WindowsIdentity identity = WindowsIdentity.GetCurrent();
aspContext = identity.Impersonate();
ContextOptions o = ContextOptions.Negotiate;
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, this._DomainName, this._DomainName Path);

UserPrincipal UPrinci = new UserPrincipal(ctx);
UPrinci = UserPrincipal.FindByIdentity(ctx, SPContext.Current.Web.CurrentUser.LoginName);
UPrinci.ChangePassword(_oldpassword.Text, _newpassword.Text);
_labelmsg.Text = "Password changed successfully!" ;
} //Try
catch (PasswordException ex)
{ //ex.Message; Catch exception.}
} //Delegate


Let me know your comments/ exceptions etc.
Will be glad to get back to you.

02 November 2010

SharePoint WebPart & ASP.Net Coding workarounds

As a SharePoint Developer there are couple of the changes in coding as compared to ASP.net application.
Few important note I would like add for my developer Friends

For Output : http://akshaya-m.blogspot.com?k=akshaya

Asp .Net Code
SharePoint Webpart Code Needs:

Get akshaya from the browser URL (http://akshaya-m.blogspot.com?k=akshaya)

Asp .Net Code
SharePoint Webpart Code Needs:

29 October 2010

SharePoint Excel Error: Unable to Load WorkBook

When trying to open a excel file many come across this exception stating :

"The workbook that you selected cannot be loaded because it contains the following features are not supported by Excel Services"

Many blog suggested for Excel Services Trusted Site Entry for the excel file referring.

However the solution that worked for me:

Give "Read permissions" to the users and they will be able to open the file using excel client.

Steps :
For more info on how to see permissions you have for users and groups in your site go to: Site Actions > Site Settings > Advanced Permissions.
Edit User Permissions to Read

Also make sure the permission are inherited to the Document Library permissions.

Revert with your Comments on the same.

12 October 2010

Warning: Super user account!

When Working on a farm environment couple of time we come across some warning stating:
"The super user account utilized by the cache is not configured...."

Temporary Solution
:: execute- 'stsadm -o setproperty -propertyname portalsuperuseraccount -propertyvalue account -url webappurl'.

Furthermore, there is the caveat:
The account should be any account that has Full Control access to the SharePoint databases but is not an application pool account. What have people done - create a special account?

After doing an extensive research i found solution as stated by Mirjam van Olst


07 October 2010

SharePoint Installation steps

For installing Sharepoint on your local system please refer this blog

Over view on Installing Sharepoint 2007by dataSprings

Over view on Installing Sharepoint 2010by SharePoint Knowledge

Custom Welcome Control

For providing enriched contents on the masterpage sharepoint has UserControls placed.

Here I'm providing couple of best link for the same.

20 July 2010

Create WebPart Properties with Drop Down Items.

Dealare field

protected WeekDays _daysWeek = WeekDays.Sun;

/// Days of the Week to be appended in the Dropdown List

public enum WeekDays
Tue, Web, Thur, Fri, Sat, Sun
/// Properties

[WebBrowsable(true)] [System.ComponentModel.Category("My Zone")]
[WebDisplayName("My DropDown Property")] [WebDescription("Get webpart properties
with DropDown")]
public WeekDays SelectedDay
{ return _daysWeek; }
{ _daysWeek = value; }

26 June 2010

Print WebPart Content Area :Sharepoint

After developing a business specific front end there is always a request for Print functionality for specific WebParts /content.

Here is a script added at SharePoint Forum (Click Here)

12 May 2010


1. List Creation:
Create two list in the web application which needs this functionality to be implemented.
  1. Category: create list named “CATEGORY “ with default Title field in it.
  2. Sub-Category: Create list named “SUB-CATEGORY” with Title & a lookup from the Category List (Title Column).
Script for Content Editor WP.
Note: For adding script get the List GUID and Default View GUID of the Sub Category List

<script type="text/javascript"> _spBodyOnLoadFunctionNames.push("PageOnLoad");
function PageOnLoad()
{ // This function will add onchange event to the Country DropDown field and call
OnChanged function. var lookupElement = GetElementByTypeAndTitle('SELECT','Category');
if ( lookupElement != null)
lookupElement.onchange = function()
} }
function OnChanged(FilterValue)
{ // siteName - the root / and possibly sub site you are working on
// lookupListName - the guid for the list you want to use as lookup
// lookupViewName - the guid for the view filtering the content of the list
// Open the List -> Settings -> List Settings -> Click on "All Items" view,
// From the URL you can get the ListName GUID and ListView GUID.
// textField - the field you want to show to the user
// valueField - this is most of the time the internal ID field
// FilterField - the field you want to be a filter
// FilterValue - the filter's value var
var lookupListName="{90533341-04F8-4353-BBEB-D6D9A0BAAC1F}";
var lookupViewName="{C6C467A6-C04D-448D-8015-D4A622784745}";
var FilterField ="Category";
var textField ="ows_LinkTitle";
var valueField ="ows_ID";
var filterElement = GetElementByTypeAndTitle('SELECT','Sub-Category');

filterElement.innerHTML = ""; var reqstring = siteName + "/_vti_bin/owssvr.dll?CS=109&XMLDATA=1&RowLimit=0&List=" + lookupListName +"&View=" + lookupViewName;

if (FilterValue != "") reqstring= reqstring +
"&FilterField1=" + escape(FilterField) + "&FilterValue1=" + escape(FilterValue);

var req = new ActiveXObject("MSXML2.XMLHTTP"); req.open("GET",reqstring,false);
// -- loading response in XML Document
var doc = new ActiveXObject("MSXML2.DOMDocument"); doc.loadXML(req.responseText); var data = doc.documentElement.childNodes(1);
for (i=0;i<data.childNodes.length;i++)
var optionText = data.childNodes(i).attributes.getNamedItem(textField).value;
var optionValue = data.childNodes(i).attributes.getNamedItem(valueField).value;
var opt = document.createElement("OPTION");

opt.innerText = optionText;
opt.value = optionValue;
} }
function GetElementByTypeAndTitle(elementType, elementTitle)
//get the Element by tag name.
var allElements = document.getElementsByTagName(elementType);
for (var i = 0; i < allElements.length; i++)
//compare the Title.
if (allElements[i].title == elementTitle) return allElements[i];
return null;

23 March 2010

Webpart :File Upload with Folder Drill Down

Development Steps:
Custom webPart is created for specific document library which populates folders and sub-folder ina dropdown control showing the folder name and file control to upload file to the selected folder/sub-folder.

1. Control initialization is carried in the CreateChildControls()
Note: since the control needs to pertain existing values in on page I referred I have enabled drop Down values true for
<DropDown_Control>.AutoPostBack = true;
<DropDown_Control>.EnableViewState = true;

2. Loading the Parent drop-down with all the parent Folders

using(SPWeb myWeb = mysite.OpenWeb())
//before selecting the Folder
ListItem listItem = new ListItem();
listItem.Text = "Select Folder";
listItem.Value = "";
myWeb.AllowUnsafeUpdates =true;
SPFolder mylibrary = myWeb.Folders[<Document Library Name>.ToString()];
SPFolderCollection AllFolders = mylibrary.SubFolders;
foreach (SPFolder folderin AllFolders)
listItem = new ListItem();
listItem.Text = folder.Name.ToString();
listItem.Value = folder.Name.ToString();
<DropDown Control_1>.Items.Add(listItem);


3. Loading the Child DropDown with-in the selected parent folders

void<DropDown Control_1>_SelectedIndexChanged(object
sender, EventArgs e)
//The code is much similar the mentioned above except few minor variations
using(myWeb = mysite.OpenWeb())
ListItem listItem = newListItem();
listItem.Text = "Select Sub-Folder";
listItem.Value = "";
<DropDown Control_2>.Items.Add(listItem);
myWeb.AllowUnsafeUpdates = true;
string_MainFolder = [<Document Library Name>.ToString();
SPFolder Mainlibrary = myWeb.Folders[_MainFolder];
SPFolder mylibrary = Mainlibrary.SubFolders[<DropDown Control_1>.SelectedValue.ToString()];
SPFolderCollection AllFolders = mylibrary.SubFolders;
foreach (SPFolder folder in AllFolders)
listItem = newListItem();
listItem.Text = folder.Name.ToString();
listItem.Value = folder.Name.ToString();
<DropDown Control_2>.Items.Add(listItem);

4. I have used a file upload control to get the local file to be uploaded

5. To upload my local file in the specified folder location selected on my Button control <Button_Control_Click Event>


void < Button_Control>_Click(object sender,
if(<FileUpload_Control>.PostedFile !=null)
if(<FileUpload_Control>.PostedFile.ContentLength > 0)
System.IO.Stream strm = <FileUpload_Control>.PostedFile.InputStream;

byte[] FileContent = new byte[ Convert.ToInt32(<FileUpload_Control>.PostedFile.ContentLength)];

strm.Read(FileContent, 0, Convert.ToInt32(<FileUpload_Control>.PostedFile.ContentLength));

// Open site where document library is created.
SPWeb myWeb = mysite.OpenWeb();

// Get the folder that should store the document In this case, there's a document library called "<Document Library Name>" within the Root Web of the Site Collection
SPFolder MainDocLib = myWeb.Folders[<Document Library Name>.ToString()];

// Within the "<Document Library Name>" library, add the document into its Parent Folder
SPFolder parent = MainDocLib.SubFolders[<DropDown Control_1>.SelectedValue.ToString()];

// Within the "<Document Library Name>" library, add the document into a Parent folder's Sub-Folder
SPFolder child =parent.SubFolders[<DropDown Control_2>.SelectedValue.ToString()];

// Upload document

myWeb.AllowUnsafeUpdates = true;

SPFile spfile = child.Files.Add(System.IO.Path.GetFileName(<FileUpload_Control >.PostedFile.FileName), FileContent,true);


<Status_Control>.Text = "File Successfully Uploaded! @"+ child.Url.ToString();
<Status_Control>.Text = "Sorry! File Not Found!";


Special Thanks: Dhawal Mehta

18 February 2010

Domain Specific Master Page/CSS Loading...

Having different Branding for alternate user is one of the most demanding requirement from a business prospective. However I have been incisive with the HTTP handler to load my masterpages for various domain based users..
Here is the simplest solution suggested & implemented by my friends which is really effective and fast to incorporate..
All my efforts were utilized in created CSS (style Sheet) and its adjacent master file..
These .CSS & .master file are uploaded on the portal’s style library.
For effective implementation I have added the following entries in the master page it self.
CSS initialization has been done in the head tag while domain checking and loading on masterpage is carried on the body.

If you want you can perform the same by using a content Editor Webpart Also.
/*.MASTER File/*


<link href="../../Shared Resources/custom.css" rel ="stylesheet" type ="text/css"
< link rel ="stylesheet" type ="text/css" title = "MasterStyle01" href =

< link rel ="stylesheet"type ="text/css" title = "MasterStyle02" href = "/Style Library/MasterStyle02.css" />


Body must include the conditions to check the User Domain and to load its corresponding master file.


<BODY scroll="yes" onload="javascript:if (typeof(_spBodyOnLoadWrapper) !=
'undefined') _spBodyOnLoadWrapper();">
<WebPartPages: contenteditorwebpart id="ContentEditorWebPart1" runat="server"
<WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2>
<Content xmlns ="http://schemas.microsoft.com/WebPart/v2/ContentEditor"> <! [CDATA[<script>
var myLoginUser = '_LogonUser_'.toLowerCase();
if (myLoginUser.indexOf('Domain01') != "-1")
for(var StyleSheetIterator = 0; StyleSheetIterator<document.styleSheets.length; StyleSheetIterator++)
if(document.styleSheets[StyleSheetIterator].title =="MasterStyle02")
{ document.styleSheets[StyleSheetIterator].disabled = false; }
if(document.styleSheets[StyleSheetIterator].title == "MasterStyle01") { document.styleSheets[StyleSheetIterator].disabled = true; }
</script>]]> </Content></WebPart> </WebPartPages:ContentEditorWebPart>

Note: check the tags existence in the master file itself before adding.
Special Thanks : Anshul Gagneja & Dhawal Mehta

17 February 2010

Sharepoint Session State

hi focks,
Here is a link I'm session state configuration in sharepoint.
Click Here blogged by Erick Kraus

Special Thanks : Erick

Rate Now: