Friday, January 4, 2013

FCKEditor validation using javascript



function ValidateFCKEditor(fckEditorClientID) {
            varError = "";
            var objFCKeditor1 = document.getElementById('<%=fckNotes.ClientID%>');
           
            if (typeof (FCKeditorAPI) != undefined) {
                var oEditor = FCKeditorAPI.GetInstance(objFCKeditor1.id);
                if (oEditor.GetXHTML(true) == "") {
                    varError += "Entering text in fckeditor is mandatory.\n";
                }
                if (varError != '') {
                    alert(varError);
                    return false;
         
                }
            }
        
                return true
      }

Wednesday, October 31, 2012

Update Date/Time in SharePoint using Object Model

string str = "2012-10-31T00:00:00Z";
DateTime date = DateTime.Parse(str);
DateTime dt1 = date.AddMinutes(15);
string foo = dt1.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'");

Friday, July 20, 2012

Get Document URL within Folder/Document Set


SPListItem item = ...;
string absUrl = (string) item[SPBuiltInFieldId.EncodedAbsUrl];

Saturday, June 30, 2012

Property Bags in SharePoint 2010

Property Bags enables the developers to add properties to the SharePoint objects like 

a. Farm (SPFarm class)
b. Web application (SPWebApplication class)
c. Site collection (SPSite class)
d. Site (SPWeb class)
e. List (SPList class)

Using Property Bags, developers can avoid storing Key/Value pairs in Web.Config or at some other location. Internally, Property bags are implemented as a hash table of property names and values.

We can set the Property Bag values using two ways:
a. Using SharePoint Designer
b. Programatically

a. Using SharePoint Designer to store Property Bags
(i). Open the site in SP Designer 2010 and click on Site Options.



To read this MyKey value, just use the below code. 

SPSite siteCollection = new SPSite("http://sharepointMoss");
SPWeb website = mySite.RootWeb;
string MyValue = website.AllProperties["MyKey"]);


b. Programatically.

Use the below code to set the property bags Programatically.
SPSite siteCollection = new SPSite("http://sharepointMoss");
SPWeb website = mySite.RootWeb;
website.Properties.Add("MyKey", "MyValue");
website.Properties.Update

CSS for Mozilla and Chrome Specific

To add Mozilla specific CSS, just include the CSS inside @-moz-document url-prefix() as shown below:
/* Mozilla Specific CSS */
 @-moz-document url-prefix()  {
    #imgHeaderTD
    {
        display:none;
    }
}

The above code hides the element with ID imgHeaderTD in Mozilla only.

To add Chrome specific CSS, just include the CSS inside  @media screen and (-webkit-min-device-pixel-ratio:0):


/* Chrome Specific CSS */
@media screen and (-webkit-min-device-pixel-ratio:0) {
    #imgHeaderTD
    {
    display:none;
    }
}

Thursday, June 14, 2012

VS 2005 Web Application Template Add-In

http://download.microsoft.com/download/9/0/6/906064ce-0bd1-4328-af40-49dca1aef87c/WebApplicationProjectSetup.msi

Friday, March 30, 2012

Two-Tier or Three Tier Architecture in SharePoint

If SharePoint Server and the database server are installed on one computer, it is a single-tier deployment.
In a two-tier deployment, SharePoint Server components and the database are installed on separate servers. In a three-tier deployment, the front-end Web servers are on the first tier, the application servers are on the second tier, which is known as the application tier, and the database server is located on the third tier.

Wednesday, February 29, 2012

Css styles not being applied for Anonymous users on sharepoint 2010

I have been stuck with the same problem and dint understand the problem for long enough....
I realized to check in as a major version and the problem solved....

Thanks a lot..

Monday, February 6, 2012

SSL Connection error in chrome 107

Go to option -> proxy settings and the standard MSIE window will pop up. Then go to advanced tab and be sure to tick:
USE SSL 2.0
USE SSL 3.0
USE TSL 1.0

Then click OK, close Chrome, open it again and it shall work.

Monday, January 30, 2012

The settings for this list have been recently changed. Refresh your browser sharepoint 2010

while the FormMode is in Edit mode you cannot call on the Update method for the list. The code works fine in display mode on the DispForm.aspx page and it will hide and show the correct fields in the EditForm.aspx page but when you click Save that is when the error is thrown. If the Update method is removed the error will not be thrown however you will not be able to see the changes to the fields.

Check list.update() method and if it is unnecessary then remove it.

Thursday, December 15, 2011

Set/Update Content Type of new upload file in document library

using (SPSite site = new SPSite(SiteSubSite))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
//Create file Stream object using save local file
FileStream fstream = File.OpenRead(sourceFilePath);
byte[] content = new byte[fstream.Length];
fstream.Read(content, 0, (int)fstream.Length);
fstream.Close();

SPFile file = web.Files.Add(targetDocumentLibraryPath, content, true);

SPContentType spPdf = file.Item.ParentList.ContentTypes[ContentType.Name.ToString()];

file.Item["ContentTypeId"] = spPdf.Id;
file.Item["Content Type"] = spPdf.Name;
file.Item.SystemUpdate();
file.Update();

}
}

Error: "Cannot open database "WSS_Content_...." requested by the login. The login failed. Login failed for user ... "

Today I am converting word to PDF file using Word Automation Service, its throw error like "Cannot open database "WSS_Content_...." requested by the login. The login failed. Login failed for user ... "

Solution :

I have open IIS manager and click on the Application pool. Selected respected site's pool and apply valid user authentication over there. After reset IIS and checked my feature.

Its Working...

Enjoy...

Sunday, December 11, 2011

Enable Riboon Button for specific list and single item selection


<CommandUIHandlers>
<CommandUIHandler Command="ListDocumentMerge_Test_Button" CommandAction="~site/_layouts/ListDocumentMerge/DocumentMerge.aspx?List={ListId}&ID={SelectedItemId}"
EnabledScript="javascript:function singleEnable() {
var items = SP.ListOperation.Selection.getSelectedItems();
var ci = CountDictionary(items);
var listId = SP.ListOperation.Selection.getSelectedList();
if (ci == 1 && listId == '{B8701B6B-8CB7-4105-852F-4C685F580A63}')
{ return true; }
return false; }
singleEnable();" />
</CommandUIHandlers>

Programmatically add Custom action in SharePoint 2010

If you need to create a ribbon button that applies to a specific list in a farm deployment scenario you must write some code in a feature event receiver to create an SPUserCustomAction class as so:
SPList list = web.Lists["SomeList"];SPUserCustomAction action = list.UserCustomActions.Add();action.Title = "Do Something";action.Description = "Sample ribbon button";action.ImageUrl = "/_layouts/images/centraladmin_backupandrestore_granularbackup_32x32.png";action.Location = "CommandUI.Ribbon.ListView";action.Sequence = 0;action.Url = "javascript:DoAction();";action.CommandUIExtension =@"<CommandUIExtension xmlns='http://schemas.microsoft.com/sharepoint/'> <CommandUIDefinitions> <CommandUIDefinition Location='Ribbon.Documents.Manage.Controls._children'> <Button Id='Sample.DoSomething.Button' Command='Sample.DoSomething' Image32by32='/_layouts/images/centraladmin_backupandrestore_granularbackup_32x32.png' Image16by16='/_layouts/images/centraladmin_backupandrestore_granularbackup_32x32.png' Sequence='0' LabelText='Do Something' Description='Sample ribbon button' TemplateAlias='o1' /> </CommandUIDefinition> </CommandUIDefinitions> <CommandUIHandlers> <CommandUIHandler Command='Sample.DoSomething' CommandAction='javascript:DoAction();' EnabledScript='javascript:EnableDoAction();'/> </CommandUIHandlers></CommandUIExtension>";
action.Update();

Hide Ribbon in SharePoint 2010

f you have a to disable / hide the SharePoint 2010 ribbon in list forms (such as New / Edit / Display forms), one of the easiest ways is to do it through CSS.

As SharePoint 2010 provides great flexibility with list forms, we can easily modify whatever is required in a particular form for a particular list.

Click "Edit List" icon in the ribbon and it will fire up SharePoint Designer. Open the form where the ribbon needs to be hidden, right click it and choose "Edit File in Avdanced Mode".

The below is div in which the ribbon resides.
<div id=”s4-ribbonrow” class=”s4-pr s4-ribbonrowhidetitle”>
...
</div>
Now to hide the ribbon, add this to the page.
<style type="text/css">
#s4-ribbonrow{ display:none; }
</style>

Custom Ribbon Menu in SharePoint 2010

Feature.xml

<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="031FE880-77CF-4A84-8C5C-7324229EDC6D"
Title="List Document Merge Custom Ribbon Button"
Scope="Web"
Description="List Document Merge Custom Ribbon Button"
ImageUrl="DOC32.GIF">

<ElementManifests>

<ElementManifest Location="RibbonButton.xml"/>

</ElementManifests>

</Feature>

RibbonButton.xml

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

<CustomAction
Id="ListDocumentMergeCustomRibbonButton"
RegistrationId="101"
RegistrationType="List"
Location="CommandUI.Ribbon"
Sequence="5"
Title="Merge Documents"
Rights="ViewListItems" xmlns="http://schemas.microsoft.com/sharepoint/"
>
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.Documents.Manage.Controls._children">
<Button
Id="Ribbon.Documents.New.ListDocumentButton"
Alt="Merge Documents"
Sequence="5"
Command="ListDocumentMerge_Test_Button"
Image32by32="/_layouts/images/DOC32.GIF"
Image16by16="/_layouts/images/DOC32.GIF"
LabelText="Merge Documents"
TemplateAlias="o1" />
</CommandUIDefinition>
</CommandUIDefinitions>

<CommandUIHandlers>
<CommandUIHandler
Command="ListDocumentMerge_Test_Button"
CommandAction="~site/_layouts/ListDocumentMerge/DocumentMerge.aspx?List={ListId}&ID={SelectedItemId}" />
</CommandUIHandlers>

</CommandUIExtension>
</CustomAction>

</Elements>

Wednesday, December 7, 2011

The type ‘System.IO.Packaging.Package’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘WindowsBase’

While I was working with the Open Office XML SDK 2.0, after I added the reference to the DocumentFormat.OpenXml assembly and tried to build the application I ran into this error message.

The type ‘System.IO.Packaging.Package’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35′

Turns out, all you need to do to fix it is to just add another reference to WindowsBase assembly that is found in the .NET Tab.