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