only My site

Friday, December 28, 2012

Sandbox Solution - Good Links

I am in a Sharepoint online project and I am limited now with Sandbox solutions. Here I need to be cautious as the visual studio allows us to write (Farm solution code), compile and make packages which will not allowed deploying in Sharepoint online. However the VS2010 plugin Power tool restricts the code which are not allowed in sandbox solution.

I know most of the limitations and I was in search to do a complete study on SB Solution and found the simple but powerful article. Here is the links

  1. Sandbox Part1
  2. Sandbox Part2
  3. Sandbox Part3
  4. Sandbox Part4
Wonderful article in MSDN
http://msdn.microsoft.com/en-us/magazine/ee335711.aspx

Feature Stapling / Feature Site Template Association

This is a very useful in many situations. For Instance, you need to activate a feature while creating a web site or sub site using some site template. The feature may have some functionality such as copy files from site collection style library to the newly created sub site, or Change the welcome welcome page and master page on creation of the site etc..

Feature stapling is the only solution as of now. The MSDN resource is good and the link is here

The following are the main points
1. We can associate a feature with one or multiple site templates
2. Feature will work for the newly created sites and not for the existing sites. Need to use some othe way for older sites.
3. Causes the attachment of a Feature to all new instances of sites that use a given site definition, without modifying the site definition or creating code routines to activate the Feature on each site. Also known as a feature site template association,
4. Another example : A developer creates a Feature and to add it to every new Web site that is based on a specific site definition. The developer creates a feature-stapling Feature that includes mappings between the Feature and site definition.
5. Technical Details : Feature stapling is implemented through a Feature that is specifically designed to staple other Features to one or more site definitions. Feature stapling allows a Feature to be stapled to any new sites created from any site definition or from specific site definitions based on the template name identified in the appropriate WEBTEMP.xml file.
6. Example

Following is an example of feature stapling that associates the Feature with only the STS site definition templates.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   <FeatureSiteTemplateAssociation Id="00BFE171-1B17-4F72-28CB-1171C0140130" TemplateName="STS#0" />
   <FeatureSiteTemplateAssociation Id="00BFE171-1B17-4F72-28CB-1171C0140130" TemplateName="STS#1" />
   <FeatureSiteTemplateAssociation Id="00BFE171-1B17-4F72-28CB-1171C0140130" TemplateName="STS#2" />
</Elements>

Following is an example of feature stapling that associates the Feature for all site definitions

<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <FeatureSiteTemplateAssociation Id="00BFE171-1B17-4F72-28CB-1171C0140130" TemplateName="GLOBAL" /> </Elements>

Tuesday, December 25, 2012

Slideshow (Carousel) in Sharepoint 2010 CQWP

We can do customization the Sharepoint CQWP according to our need. Here is the one of the complex implementation of shideshow using jquery, css and CQWP. The article is well narrated with shreen shots. The Key elments are ItemStyle.xsl and ContentQueryMain.xsl.




https://www.nothingbutsharepoint.com/sites/eusp/Pages/SharePoint-Integrate-a-Slider-with-the-Content-Query-Web-Part-Part-1-What-does-my-Slider-Need-to-Work.aspx

https://www.nothingbutsharepoint.com/sites/eusp/Pages/SharePoint-Integrating-a-Slider-with-the-Content-Query-Web-Part-Part-2-Setting-up-my-Content-Source.aspx

https://www.nothingbutsharepoint.com/sites/eusp/Pages/SharePoint-Integrate-a-Slider-with-the-Content-Query-Web-Part-Part-3-Integration-with-the-CQWP.aspx

Known Issue and Resolution

While Implementing the above slider i had the following Issues.

Error :
"The web part references an untrusted XSL file. Only XSL files contained in this site's Style Library may be referenced"

Cause :
The path was pointing to the wrong location. Instead of "sites/MySiteCollectionName/Style Library/Xsl Style Sheets" location, it is pointing to "/Style Library/Xsl Style Sheets".

Resolution :
Change the properties in the CQWP File (export the web part and open it in notepad). Possibly we need to change the following file path properties
1. ItemXslLink - Example /sites/rd/Style Library/Xsl Style Sheets/Slider/ITemStyle.xsl
2. MainXslLink - Example /sites/rd/Style Library/Xsl Style Sheets/Slider/ContentQueryMain.xsl
3. Xsl

In the ContentQueryMain.xsl file, the following needs to be done
1. Add the jquery file (jquery.min.js) link in the code above the global.css. This may not required if the jquery link is available in Master page.
2. use ../ prefix for the "/Style Library" (if it is hosted in sites/rd)

Yet Another Slideshow with full code

http://chrisstahl.wordpress.com/2011/08/09/image-slideshow-with-cqwp-in-sharepoint-2010/

Item style customization steps

http://www.heathersolomon.com/blog/articles/customitemstyle.aspx

Friday, December 21, 2012

SharePoint with jQuery, SPServices, and the Google Maps API



Use SharePoint with jQuery, SPServices, and the Google Maps API to create a fun solution for end-users to add markers to a map. Find the full code on www.bentedder.com

Sharepoint Brand Designers - MasterPage, CSS, JQuery ..

Sharepoint Brand Designers http://chrisstahl.wordpress.com/

Friday, December 14, 2012

Content Query Web Part (CQWP) - SP2010 OOB Feature




Editing Properties in CQWP


The following are the key properties of CQWP : CommonViewFields, DataColumnRenames, QueryOverride



Tuesday, December 4, 2012

Creating mobile apps with SharePoint 2013


Friday, November 23, 2012

Grid & DataTable Tips


The below is the sample to show a alert message in the ASP.Net Grid View

int intTotalColumns = grdGRIDName.Rows[0].Cells.Count;
grdGRIDName.Rows[0].Cells.Clear();
grdGRIDName.Rows[0].Cells.Add(new TableCell());
grdGRIDName.Rows[0].Cells[0].ColumnSpan = intTotalColumns;
grdGRIDName.Rows[0].Cells[0].Text = "No records are found!";
grdGRIDName.Rows[0].Cells[0].Style.Add("text-align", "Center");
grdGRIDName.Rows[0].Cells[0].Style.Add("color", "red");

The below is the sample to filter the Data in a DataTable using column name and value.

DataTable users = (DataTable)Session[DB_USERS];

var items = users.AsEnumerable().Where(p => p.Field<string>("FIELD_NAME").Contains(value));

Modernizr - A Javascript library



What Is Modernizr
It is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.

Why use Modernizr?
Taking advantage of cool new web technologies is great fun, until you have to support browsers that lag behind. Modernizr makes it easy for you to write conditional JavaScript and CSS to handle each situation, whether a browser supports a feature or not. It’s perfect for doing progressive enhancement easily.

How it works
Modernizr runs quickly on page load to detect features; it then creates a JavaScript object with the results, and adds classes to the html element for you to key your CSS on. Modernizr supports dozens of tests, and optionally includes YepNope.js for conditional loading of external .js and .css resources.


Source : Internet

Sunday, November 18, 2012

Asyncronous Deligate with Callback method & BeginInvoke



BeginInvoke method : Executes the specified delegate asynchronously with the specified arguments, on the thread that the control's underlying handle was created on.
 
using System;
using System.Threading;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;

namespace AsyncInvoke
{

    // Create an asynchronous delegate.
    public delegate bool FactorizingAsyncDelegate(
             int factorizableNum,
             ref int primefactor1,
             ref int primefactor2
    );

    // Create a class that factorizers the number.
    public class PrimeFactorizer
    {
        public bool Factorize(
                     int factorizableNum,
                     ref int primefactor1,
                     ref int primefactor2)
        {
            primefactor1 = 1;
            primefactor2 = factorizableNum;

            // Factorize using a low-tech approach.
            for (int i = 2; i < factorizableNum; i++)
            {
                if (0 == (factorizableNum % i))
                {
                    primefactor1 = i;
                    primefactor2 = factorizableNum / i;
                    break;
                }
            }

            if (1 == primefactor1)
                return false;
            else
                return true;
        }
    }

    // Class that receives a callback when the results are available.
    public class ProcessFactorizedNumber
    {
        private int _ulNumber;

        public ProcessFactorizedNumber(int number)
        {
            _ulNumber = number;
        }

        // Note that the qualifier is one-way.
        [OneWayAttribute()]
        public void FactorizedResults(IAsyncResult ar)
        {
            int factor1 = 0, factor2 = 0;

            // Extract the delegate from the AsyncResult. 
            FactorizingAsyncDelegate fd = (FactorizingAsyncDelegate)((AsyncResult)ar).AsyncDelegate;

            // Obtain the result.
            fd.EndInvoke(ref factor1, ref factor2, ar);

            // Output the results.
            Console.WriteLine("On CallBack: Factors of {0} : {1} {2}",
                          _ulNumber, factor1, factor2);
        }
    }

    // Class that shows variations of using Asynchronous
    public class Simple
    {
        // The following demonstrates the Asynchronous Pattern using a callback.
        public void FactorizeNumber1()
        {
            // The following is the client code.
            PrimeFactorizer pf = new PrimeFactorizer();
            FactorizingAsyncDelegate fd = new FactorizingAsyncDelegate(pf.Factorize);

            int factorizableNum = 1000589023, temp = 0;

            // Create an instance of the class that is going
            // to be called when the call completes.
            ProcessFactorizedNumber fc = new ProcessFactorizedNumber(factorizableNum);

            // Define the AsyncCallback delegate.
            AsyncCallback cb = new AsyncCallback(fc.FactorizedResults);

            // You can use any object as the state object.
            Object state = new Object();

            // Asynchronously invoke the Factorize method on pf.
            IAsyncResult ar = fd.BeginInvoke(
                                 factorizableNum,
                                 ref temp,
                                 ref temp,
                                 cb,
                                 state);

            //
            // Do some other useful work.
            //. . .
        }

        // The following demonstrates the Asynchronous Pattern using a BeginInvoke, followed by waiting with a time-out.
        public void FactorizeNumber2()
        {
            // The following is the client code.
            PrimeFactorizer pf = new PrimeFactorizer();
            FactorizingAsyncDelegate fd = new FactorizingAsyncDelegate(pf.Factorize);

            int factorizableNum = 1000589023, temp = 0;

           // Asynchronously invoke the Factorize method on pf.
            IAsyncResult ar = fd.BeginInvoke(
                              factorizableNum,
                              ref temp,
                              ref temp,
                              null,
                              null);

            ar.AsyncWaitHandle.WaitOne(10000, false);
           
            if ( ar.IsCompleted )
            {
                int factor1 = 0, factor2 = 0;

                // Obtain the result.
                fd.EndInvoke(ref factor1, ref factor2, ar);

                // Output the results.
                Console.WriteLine("Sequential : Factors of {0} : {1} {2}", factorizableNum, factor1, factor2);

            }
        }

        public static void Main(String[] args)
        {
            Simple simple = new Simple();
            //simple.FactorizeNumber1();
            simple.FactorizeNumber2();

            Console.ReadLine();
        }
    }

}