22 May 2011

How to design a form of SharePoint 2010 List with InfoPath 2010

At the time I showed how to design a form using SharePoint Designer 2007. This time I will demonstrate how to design using InfoPath 2010 in the form of a SharePoint List for SharePoint 2010.

Follow these steps:
1. Opens the list in SharePoint Designer 2010
2. On the ribbon, in the List Settings tab, click Design Forms in InfoPath and choose Item.


Now open the InfoPath 2010


3. On the ribbon, in the Page Disign We will choose the Page Layout

4. We point out the field - and we'll get a menu.
5. In the Rules section, click Add Rule and select manage rules.

6. On the Rules task pane we have Validation, Formatting And Action 


7. For example - create a new rule. We choose Action.
 On the Rules task pane, in the Formatting section


8.  We define our Action

9. Click the top right close control on the Rules task pane to close it.
10. Click the File menu at the top left of the screen.
11. Choose Quick Publish (Your form is published to your SharePoint site).
12. Now we can check the list with the Browser .

I'm so good design - that it looks perfect

21 May 2011

Create a SharePoint 2010 List with SharePoint Designer

At the time I explained how to create a list using PowerShell. Today I will demonstrate how to create a list in SharePoint 2010 in SharePoint Designer 2010.

1. Opened the SPD 2010
2.In the left hand navigation menu, click "Lists and Libraries".

3. In the main window, in the List section, select the "SharePoint List" Ribbon
4. Selected "Custom List"

5. We need to define the name of the list and the description

6. Selected the "Add New Column" Ribbon

7. Now we define the fields
Now we have the SharePoint List

Thanks...
Roi

18 May 2011

New on framework 4 - Parallel

Not long ago, I started to learn what's new on framework 4 (Not that it was in sight in the SharePoint - still stuck at 3.5)

Anyway, I took a sample from "Love the Dot"
There is a new concept in the framework 4 - Parallel
Parallel gives us to use the computer's CPU resources
They are a small example - I will present for two loops of
The first is the Parallel method
Parallel.For (0, 250, (i) =>
Second - we know from ancient man ovalness
for (int i = 0; i <250; i + +)

Here's the code

using System;
using System.Diagnostics;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            Stopwatch watch = new Stopwatch();
            watch.Start();
            Parallel.For(0, 250, (i) =>
            {
                RandomMix(i);
            }
            );
            watch.Stop();
            Console.WriteLine(String.Format("Parallel.For tooks {0} milliseconds", watch.ElapsedMilliseconds));
            watch = new Stopwatch();
            watch.Start();
            for (int i = 0; i < 250; i++)
            {
                RandomMix(i);
            }
            watch.Stop();
            Console.WriteLine(String.Format("for tooks {0} milliseconds", watch.ElapsedMilliseconds));
            Console.ReadLine();
        }
        private static void RandomMix(int instance) 
        { 
            double result = Math.Acos(new Random().NextDouble()) * Math.Atan2(new Random().NextDouble(), new Random().NextDouble());  
            for (int i = 0; i < 20000; i++)  
            { 
                result += (Math.Cos(new Random().NextDouble()) * Math.Acos(new Random().NextDouble())); 
            }  
        }
    }
}


This result (notice the picture with multiple processors)

Parallel.For tooks 2.6 sec
for tooks 22.1 sec

Amazing - it really works
For those interested there is also continuing on - Parallel LINQ (PLINQ)

14 May 2011

How to get a display form in sharepoint public site

This time I will present to you the difference between the two ways that would have the display form (or new/edit) in sharepoint public site .

As I explained before, I had to activate the "Lockdown Feature" to lock the form from public Web site. Also, I said that if we want to see our form, we must create a new custom form using SharePoint designer. The SPD will help us to carry out the redirect (with "Supporting Files").

I was asked Yesterday to create a WebPart that displays links that lead to the Item list (our custom form).
I know the code that refers to display form
list.Forms[PAGETYPE.PAGE_DISPLAYFORM].ServerRelativeUrl;
The problem is that this code refers to the original form (from list folder) and the "lockdown feature" lock me this path (401 unauthorized).
How I will get my form?
Solving this problem I created a Console Application that will help me



I found the following code:
list.ContentTypes[0].DisplayFormUrl
To get the real form I need to go list ContentType, and then to get the real form.
Of course to get the path you will need to concatenate list.ParentWebUrl
Here is the code of my Console Application:

using Microsoft.SharePoint;
namespace ConsoleApplication1
{
   class Program 
   {
        static void Main(string[] args)
        {
           using (SPSite site = new SPSite("http://mysite/"))
           {
               using (SPWeb web = site.OpenWeb())
               {

                   SPList list = web.Lists["mylist"];

                   string url1 = list.Forms[PAGETYPE.PAGE_DISPLAYFORM].ServerRelativeUrl;

                   string url2 = list.ContentTypes[0].DisplayFormUrl;

               }

           }

        }

    }
}

10 May 2011

How to install and work with lockdown feature in SharePoint

Lockdown Feature - if you want to lock anonymous users out of your SharePoint Forms pages on public site, Follow these steps:


1. Write this command on the server

stsadm.exe –o activatefeature –url http://YourSite -name ViewFormPagesLockDown

2. Define Anonymous

2.1 Go to: Central Administration > Application Management > Authentication providers



2.2 Choose your site

2.3 Anonymous Access -> Enable anonymous access



Now go to your site and define the site Anonymous.

2.3 Site Actions > Site Settings > Modify All Site Setting

Users and Permissions > Advanced permissions > Actions > Anonymous Access > All sites

Tips:

1 - If you broken your Permissions you will need to it (2.3) to all your sites
2 - Look this link: Work with a SharePoint list and Lockdown Feature