Unable to connect to the database SharePoint_Config on Server. Check the database connection information and make sure that the database server is running..


Hi,

While trying to open a SharePoint Site, we were getting the following error in the event log.

Unable to connect to the database SharePoint_Config on Server.  Check the database connection information and make sure that the database server is running..

The password of the  account that was specified within the Identity tab of App Pool of the site had changed.

Correcting it resolved the issue.

Bye..

Get Value for Person or Group Column Type


To get the value for Person or Group Column Type after removing the special characters from it, use this function

private string  GetValue(SPListItem item, SPField gpField)
{
    string currentValue = item[gpField.Title].ToString();
    SPFieldLookup field = (SPFieldLookup)gpField;
    SPFieldLookupValue fieldValue = (SPFieldLookupValue)field.GetFieldValue(currentValue);
    return fieldValue.LookupValue;
}

to call it

string strName = GetValue(spListItem, spListItem.Fields["fieldName"]);

 

Bye..

JavaScript on click of Finish Button in Survey – SharePoint


Hi,

We had created a survey and wanted some message to appear when user clicks on finish button.

Through one of my colleague i came to know about this function — PreSaveAction

function PreSaveAction()
{
alert(“Thanks for the participating in the survey!”);
return true;
}

Placing the above function in the newform.aspx using SharePoint designer  did the trick.

We could use the PreSaveAction function for custom validation as well !

http://edinkapic.blogspot.com/2007/10/add-javascript-date-validation-into.html

Bye..

Sort SPFolder in SharePoint


We developed a web part showing the folders hierarchy using tree view control. However the folders were not getting displayed in the tree view node in the order they are visible inside the document library i.e. sorted on name.

Creating a tree view

http://www.davehunter.co.uk/Blog/Lists/Posts/Post.aspx?List=f0e16a1a-6fa9-4130-bcab-baeb97ccc4ff&ID=115

So finally used the following code to sort the folders

List<SPFolder> folderList = new List<SPFolder>();

foreach (SPFolder myFolder in folder.SubFolders){

folderList.Add(myFolder);

}

folderList.Sort(delegate(SPFolder p1, SPFolder p2) { return p1.Name.CompareTo(p2.Name); });

For more information on sorting

http://www.developerfusion.com/code/5513/sorting-and-searching-using-c-lists/

Bye..

File not found error in NewDwp.aspx SharePoint


Hi,

I was getting this error while trying to all a new custom web part to the site.

Searching for the same found out the reason for that

It happens when you install smart part

http://www.codeplex.com/smartpart

But haven’t installed asp.net ajax 1.0 version !

http://www.microsoft.com/downloads/details.aspx?FamilyID=ca9d90fa-e8c9-42e3-aa19-08e2c027f5d6&displaylang=en

Follow it with an iis reset !!

Bye ..

Understanding Application Pages and Site Pages


Pages that support user customization are known as site pages. E.g. the page that we could see inside our SharePoint designer like default.aspx (home page), NewForm, EditForm,DispForm.aspx etc. The site pages could easily be customized without making any changes to the local file system of the front-end web server and without any need of developer involved for that. This is possible by storing the customized version of the aspx and master page files inside the content database. The saving and retrievig of content from the database is provided using SPVirutalPathProvider class. 

More on SPVirtualPathProvider

http://weblogs.asp.net/scottgu/archive/2005/11/27/431650.aspx

Site pages could exist either in customized(unghosted) or uncustomized(ghosted) state.

For e.g. when we create a new site using one of the default templates, the site as well as pages therin are in uncustomized state i.e. they are based on page templates that live on the file system of the front-end web server. Page template are used for provisioning (creating) page intances. As long as the page is not customized using SharePoint designer or through the Site Settings option the copy of the page is not stored in the content database and the pages are loaded from the file system of the web server. A single page template is compiled into an assembly and loaded into memory of IIS worker process one per web application.

However when page is customized, SPVirtualPathProvider retrieves the customized version of the page from the content database and passes it to ASP.NET parser. Now these pages aren’t compiled into assembly. They are processed by ASP.NET parser in no-compile mode.

No-comiple pages provide higher levels of scalability compared to compiled pages. Compiled pages offer following benefits

·         Performance   Compiled code is much faster than scripting languages such as ECMAScript or VBScript because it is a closer representation to machine code and does not require additional parsing.

·         Security   Compiled code is more difficult to reverse engineer than non-compiled source code because it lacks the readability and abstraction of a high-level language. Additionally, there are obfuscation tools that make compiled code even more resistant to reverse engineering.

However these compiled pages cannot be loaded into memory and unloaded in a manner similar to no-compile pages. .NET framework doesn’t support concept of unloading an assembly DLL from memory. By recycling the current Windows process or AppDomain it is possible to unload the dll, the issues is that it would unload all dll’s from memory, not any specific as desired. And moreover there is limit associated with number of assemblies that could be loaded in a .NET AppDomain.

With no compiled pages there is no requirement of loading assemblies into the memory. Processing for compiled pages is done by loading control trees into memory. Once the processing is finished for a customized page, the page’s control tree is unloaded to free up memory resources. And also as the pages are not compiled, it provides faster response time for pages upon first access.

No Compile Pages enables improved scaling for large sites with 1000s of pages, as windows has limit on number of DLLs loaded into an app and perf degrades as you hit this limit.

Application pages are pages that don’t support customization. They cannot be customized using SharePoint designer. E.g. settings.aspx, create.aspx etc.

These pages are deployed at \Layouts directory of 12 hive and are available to all the sites. They are compiled into a single dll and loaded into memory once per web application. They are used extensively for provisioning and administrating sites as well as elements inside the sites. Application pages links to application.master.

So main differences between these two types of pages could be summarized as  

1)      Site pages support customization whereas application pages don’t.

2)      Site pages once customized run in no-compile mode whereas application pages are always compiled.

3)      Now as site pages support customization it involves risk so under default security policy enforced by WSS we couldn’t write inline code in it  whereas it is allowed to write in-line code in case of application page.

4)      Application page scale better than site page. 

Bye..