Monday, May 13, 2013

Topic 1 : Working with the SharePoint User Interface

Working with the SharePoint User Interface

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
<script src="LearningScript.js" type="text/javascript"></script>
</asp:Content>

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
  <input id="Button1" type="button" value="Add Notification" onclick="AddNotification()" />
    <input id="Button2" type="button" value="Remove Notification" onclick="RemoveNotification()" />
    <p></p>
    <input id="Button3" type="button" value="Add Status" onclick="AddStatus()" />
    <input id="Button4" type="button" value="Remove Last Status" onclick="RemoveLastStatus()" />
    <input id="Button5" type="button" value="Remove All Status" onclick="RemoveAllStatus()" />

</asp:Content>

var statusId = '';
var notifyId = '';
function AddNotification() {
    notifyId = SP.UI.Notify.addNotification("Hello World!", true);
}
function RemoveNotification() {
    SP.UI.Notify.removeNotification(notifyId);
    notifyId = '';
}
function AddStatus() {
    statusId = SP.UI.Status.addStatus("Status good!");
    SP.UI.Status.setStatusPriColor(statusId, 'red');
}
function RemoveLastStatus() {
    SP.UI.Status .removeStatus(statusId);
    statusId = '';
}
function RemoveAllStatus() {
    SP.UI.Status.removeAllStatus(true);
}

Add Dialog box
function showDialog() {

var options = SP.UI.$create_DialogOptions();options.url =
"ApplicationPage1.aspx";options.height = 300;
SP.UI.ModalDialog.showModalDialog(options);
}

http://msdn.microsoft.com/en-us/library/gg552606(v=office.14).aspx


Add a custom Ribbon Tab


Creating a SharePoint Project
--------------------------------------------------------------------------------
To add a new tab, you start by creating an empty SharePoint project.
To create a SharePoint Project
1.Start Visual Studio 2010.
2.On the File menu, point to New, and then click Project.
3.In Project Types, under Visual Basic or C#, select Empty SharePoint Project.
4.Type AddARibbonTab as the project name, and then click OK.
5.In the SharePoint Customization Wizard, select Deploy as a sandboxed solution, and then click Finish.
Adding a new Feature
--------------------------------------------------------------------------------
You customize the ribbon by using a Feature. The following steps add a new Feature to your solution.
To add a new Feature
1.In Solution Explorer, right-click Features, and then select Add Feature.
2.Change the Title of the Feature to Custom Ribbon Tab.
3.In Solution Explorer, right-click Feature1, and then select Rename. Type CustomRibbonTab as the new name.
4.In Solution Explorer, right-click the AddARibbonTab project, point to Add, and then click New Item.
5.In the Add New Item dialog box, select the Empty Element template. Enter CustomRibbonTab as the name.
Defining the Custom Action
--------------------------------------------------------------------------------
The ribbon customization is defined by using ribbon XML in a custom action. For an in-depth explanation of the ribbon XML, see Server Ribbon XML.
To define the custom action
1.Open the Elements.xml file.
2.Paste the following ribbon XML into the Elements.xml file. This adds a new My Custom Tab tab with a group and three buttons on a document library.

  1. <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction
        Id="MyCustomRibbonTab"
        Location="CommandUI.Ribbon.ListView"
        RegistrationId="101"
        RegistrationType="List">
          <CommandUIExtension>
            <CommandUIDefinitions>
              <CommandUIDefinition
                Location="Ribbon.Tabs._children">
                <Tab
                  Id="Ribbon.CustomTabExample"
                  Title="My Custom Tab"
                  Description="This holds my custom commands!"
                  Sequence="501">
                <Scaling
                  Id="Ribbon.CustomTabExample.Scaling">
                  <MaxSize
                    Id="Ribbon.CustomTabExample.MaxSize"
                    GroupId="Ribbon.CustomTabExample.CustomGroupExample"
                    Size="OneLargeTwoMedium"/>
                  <Scale
                    Id="Ribbon.CustomTabExample.Scaling.CustomTabScaling"
                    GroupId="Ribbon.CustomTabExample.CustomGroupExample"
                    Size="OneLargeTwoMedium" />
                </Scaling>
                <Groups Id="Ribbon.CustomTabExample.Groups">
                  <Group
                    Id="Ribbon.CustomTabExample.CustomGroupExample"
                    Description="This is a custom group!"
                    Title="Custom Group"
                    Sequence="52"
                    Template="Ribbon.Templates.CustomTemplateExample">
                    <Controls Id="Ribbon.CustomTabExample.CustomGroupExample.Controls">
                      <Button
                        Id="Ribbon.CustomTabExample.CustomGroupExample.HelloWorld"
                        Command="CustomTabExample.HelloWorldCommand"
                        Sequence="15"
                        Description="Says hello to the World!"
                        LabelText="Hello, World!"
                        TemplateAlias="cust1"/>
                      <Button
                        Id="Ribbon.CustomTabExample.CustomGroupExample.GoodbyeWorld"
                        Command="CustomTabExample.GoodbyeWorldCommand"
                        Sequence="17"
                        Description="Says good-bye to the World!"
                        LabelText="Good-bye, World!"
                        TemplateAlias="cust2"/>
                      <Button
                        Id="Ribbon.CustomTabExample.CustomGroupExample.LoveWorld"
                        Command="CustomTabExample.LoveWorldCommand"
                        Sequence="19"
                        Description="Says I love the World!"
                        LabelText="I love you, World!"
                        TemplateAlias="cust3"/>
                    </Controls>
                  </Group>
                </Groups>
              </Tab>
            </CommandUIDefinition>
            <CommandUIDefinition Location="Ribbon.Templates._children">
              <GroupTemplate Id="Ribbon.Templates.CustomTemplateExample">
                <Layout
                  Title="OneLargeTwoMedium"
                  LayoutTitle="OneLargeTwoMedium">
                  <Section Alignment="Top" Type="OneRow">
                    <Row>
                      <ControlRef DisplayMode="Large" TemplateAlias="cust1" />
                    </Row>
                  </Section>
                  <Section Alignment="Top" Type="TwoRow">
                    <Row>
                      <ControlRef DisplayMode="Medium" TemplateAlias="cust2" />
                    </Row>
                    <Row>
                      <ControlRef DisplayMode="Medium" TemplateAlias="cust3" />
                    </Row>
                  </Section>
                </Layout>
              </GroupTemplate>
            </CommandUIDefinition>
          </CommandUIDefinitions>
          <CommandUIHandlers>
            <CommandUIHandler
              Command="CustomTabExample.HelloWorldCommand"
              CommandAction="javascript:alert('Hello, world!');" />
            <CommandUIHandler
              Command="CustomTabExample.GoodbyeWorldCommand"
              CommandAction="javascript:alert('Good-bye, world!');" />
            <CommandUIHandler
              Command="CustomTabExample.LoveWorldCommand"
              CommandAction="javascript:alert('I love you, world!');" />
          </CommandUIHandlers>
        </CommandUIExtension>
      </CustomAction>
    </Elements>

Deploying the Customization
--------------------------------------------------------------------------------
  1. Because the project was set up as a sandboxed solution, it is deployed to the Solution Gallery.
  2. To deploy the customization
    1.Press F5. The SharePoint development tools in Visual Studio 2010 automatically build and deploy the Feature.
  3. 2.Navigate to a document library in your site or subsite.
  4. 3.Click the My Custom Tab tab, observe the Custom Group, and then click the Hello, World, Good-bye, World, or I Love You, World buttons.


Walkthrough: Adding a Group to the Server Ribbon

SharePoint 2010 0 out of 5 rated this helpful - Rate this topic Published: May 2010
This topic describes how to add a new group to the Server ribbon in Microsoft SharePoint Foundation. To add a group, you identify the tab on the ribbon where the group will appear. You also define the controls inside the group and decide how the group will render those controls. The following procedure adds a new group to the Page tab for a website.
Prerequisites
--------------------------------------------------------------------------------
Microsoft SharePoint Foundation 2010
SharePoint development tools in Microsoft Visual Studio 2010
Creating a SharePoint Project
--------------------------------------------------------------------------------
To add a new group, you start by creating an empty SharePoint project.
To create a SharePoint project
1.Start Visual Studio 2010.
2.On the File menu, point to New, and then click Project.
3.In Project Types, under Visual Basic or C#, select Empty SharePoint Project.
4.Type AddARibbonGroup as the project name, and then click OK.
5.In the SharePoint Customization Wizard, select Deploy as a sandboxed solution, and then click Finish.
Adding a New Feature
--------------------------------------------------------------------------------
You customize the ribbon by using a Feature. The following steps add a new Feature to your solution.
To add a new Feature
1.In Solution Explorer, right-click Features and then select Add Feature.
2.Change the Title of the Feature to Custom Ribbon Group.
3.In Solution Explorer, right-click Feature1, and then select Rename. Type CustomRibbonGroup as the new name.
4.In Solution Explorer, right-click the AddARibbonGroup project, point to Add, and then click New Item.
5.In the Add New Item dialog box, select the Empty Element template. Type CustomRibbonGroup as the Name.
Defining the Custom Action
--------------------------------------------------------------------------------
The ribbon group is defined by using ribbon XML in a custom action. This identifies where the group will appear on the ribbon. For an in-depth explanation of the ribbon XML, see Server Ribbon XML.
To define the custom action
1.Open the Elements.xml file.
2.Paste the following XML into the Elements.xml file. This XML adds a new Custom group with two buttons on the Page tab for a website.
 Important 
You must replace the Image32by32 and Image16by16 attributes with valid image URLs.

XMLCopy

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
    Id="Ribbon.WikiPageTab.CustomGroup"
    Location="CommandUI.Ribbon">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
          Location="Ribbon.WikiPageTab.Groups._children">
          <Group
            Id="Ribbon.WikiPageTab.CustomGroup"
            Sequence="55"
            Description="Custom Group"
            Title="Custom"
            Command="EnableCustomGroup"
            Template="Ribbon.Templates.Flexible2">
            <Controls Id="Ribbon.WikiPageTab.CustomGroup.Controls">
              <Button
                Id="Ribbon.WikiPageTab.CustomGroup.CustomGroupHello"
                Command="CustomGroupHelloWorld"
                Image16by16="Insert an image URL here."
                Image32by32="Insert an image URL here."
                LabelText="Hello, World"
                TemplateAlias="o2"
                Sequence="15" />
              <Button
                Id="Ribbon.WikiPageTab.CustomGroup.CustomGroupGoodbye"
                Command="CustomGroupGoodbyeWorld"
                Image16by16="Insert an image URL here."
                Image32by32="Insert an image URL here."
                LabelText="Good-bye, World"
                TemplateAlias="o2"
                Sequence="18" />
            </Controls>
          </Group>
        </CommandUIDefinition>
        <CommandUIDefinition
          Location="Ribbon.WikiPageTab.Scaling._children">
          <MaxSize
            Id="Ribbon.WikiPageTab.Scaling.CustomGroup.MaxSize"
            Sequence="15"
            GroupId="Ribbon.WikiPageTab.CustomGroup"
            Size="LargeLarge" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
          Command="EnableCustomGroup"
          CommandAction=”javascript:return true;” />
        <CommandUIHandler
          Command="CustomGroupHelloWorld"
          CommandAction="javascript:alert('Hello, world!');" />
        <CommandUIHandler
          Command="CustomGroupGoodbyeWorld"
          CommandAction="javascript:alert('Good-bye, world!');" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>
Deploying the Customization
--------------------------------------------------------------------------------
Because the project was set up as a sandboxed solution, it is deployed to the Solution Gallery.
To deploy the customization
1.Press F5. The SharePoint development tools in Visual Studio 2010 automatically build and deploy the Feature.
2.Navigate to the home page of your site or subsite.
3.Click the Page tab, look for the Custom group, and click the Hello, World or Good-bye, World buttons.



Walkthrough: Adding a Button to the Server Ribbon

SharePoint 2010 This topic has not yet been rated - Rate this topic Published: May 2010
This topic describes how to add a new button to the Server ribbon in Microsoft SharePoint Foundation.
Prerequisites
--------------------------------------------------------------------------------
Microsoft SharePoint Foundation 2010
SharePoint development tools in Microsoft Visual Studio 2010
Creating a SharePoint Project
--------------------------------------------------------------------------------
To add a new button, you start by creating an empty SharePoint project.
To create a SharePoint project
1.Start Microsoft Visual Studio 2010.
2.On the File menu, point to New, and then click Project.
3.In Project Types, under Visual Basic or C#, select Empty SharePoint Project.
4.Type AddARibbonButton as the project name. Click OK.
5.In the SharePoint Customization Wizard, select Deploy as a sandboxed solution, and then click Finish.
Adding a new Feature
--------------------------------------------------------------------------------
You customize the ribbon by using a Feature. The following steps add a new Feature to your solution.
To add a new Feature
1.In Solution Explorer, right-click Features, and then click Add Feature.
2.Change the Title of the Feature to Custom Ribbon Button.
3.In Solution Explorer, right-click Feature1, and then click Rename. Type CustomRibbonButton as the new name.
4.In Solution Explorer, right-click the AddARibbonButton project, point to Add, and then select New Item.
5.In the Add New Item dialog box, select the Empty Element template. Type CustomRibbonButton as the name.
Defining the Custom Action
--------------------------------------------------------------------------------
You define the ribbon button by using ribbon XML in a custom action. For an in-depth explanation of the ribbon XML, see Server Ribbon XML.
To define the custom action
1.Open the Elements.xml file.
2.Paste the following XML into the Elements.xml file. This XML adds a new button on the Library tab in the Share & Track group for a document library.
 Important 
You must replace the Image32by32 and Image16by16 attributes with valid image URLs.

XMLCopy
 <?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
    Id="Ribbon.Library.Actions.AddAButton"
    Location="CommandUI.Ribbon"
    RegistrationId="101"
    RegistrationType="List"
    Title="Add a Ribbon Button">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
          Location="Ribbon.Library.Share.Controls._children">
          <Button Id="Ribbon.Library.Share.NewRibbonButton"
            Command="NewRibbonButtonCommand"
            Image16by16="Insert an image URL here."
            Image32by32="Insert an image URL here."
            LabelText="Hello World"
            TemplateAlias="o2" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
          Command="NewRibbonButtonCommand"
          CommandAction="javascript:alert('Hello, world');" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>
Deploying the Customization
--------------------------------------------------------------------------------
Because the project was set up as a sandboxed solution, it is deployed to the Solution Gallery.
To deploy the customization
1.Press F5. The SharePoint development tools in Visual Studio 2010 automatically build and deploy the Feature.
2.Navigate to a document library in your site or subsite.
3.Click the Library tab, look in the Share & Track group, and click the Hello World button.


Walkthrough: Removing a Button from the Server Ribbon

SharePoint 2010
1 out of 3 rated this helpful - Rate this topic

Published: May 2010
This topic describes how to remove a button from the Server ribbon in Microsoft SharePoint Foundation.
SharePoint Foundation 2010
SharePoint development tools in Microsoft Visual Studio 2010
To remove a button, you start by creating an empty SharePoint project.

To create a SharePoint project

  1. Start Visual Studio 2010.
  2. On the File menu, point to New, and then click Project.
  3. In Project Types, under Visual Basic or C#, select Empty SharePoint Project.
  4. Type RemoveARibbonButton as the project name, and then click OK.
  5. In the SharePoint Customization Wizard, select Deploy as a sandboxed solution, and then click Finish.
You customize the ribbon by using a Feature. The following steps add a new Feature to your solution.

To add a new Feature

  1. In Solution Explorer, right-click Features, and then select Add Feature.
  2. Change the Title of the Feature to Remove a Ribbon Button.
  3. In Solution Explorer, right-click Feature1, and then click Rename. Type RemoveARibbonButton as the new name.
  4. In Solution Explorer, right-click the RemoveARibbonButton project, point to Add, and then click New Item.
  5. In the Add New Item dialog box, select the Empty Element template. Type RemoveARibbonButton as the name.
You remove the ribbon button by using the Location attribute of the CommandUIDefinition element. The default values for ribbon buttons are listed in Default Server Ribbon Customization Locations. For an in-depth explanation of the ribbon XML, see Server Ribbon XML.

To define the custom action

  1. Open the Elements.xml file.
  2. Paste the following XML into the Elements.xml file. This XML removes the Connect to Outlook button on the Library tab in the Connect & Export group for a document library.
    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction
        Id="RemoveRibbonButton"
        Location="CommandUI.Ribbon">
          <CommandUIExtension>
            <CommandUIDefinitions>
              <CommandUIDefinition
                Location="Ribbon.Library.Actions.ConnectToClient" />
            </CommandUIDefinitions>
          </CommandUIExtension>
      </CustomAction>
    </Elements>
    
Because the project was set up as a sandboxed solution, it is deployed to the Solution Gallery.

To deploy the customization

  1. Press F5. The SharePoint development tools in Visual Studio 2010 automatically build and deploy the Feature.
  2. Navigate to a document library in your site or subsite.
  3. Click the Library tab, look in the Connect & Export group, and observe the absence of the Connect to Outlook button.

Walkthrough: Replacing a Button on the Server Ribbon

SharePoint 2010
This topic has not yet been rated - Rate this topic

Published: May 2010
This topic describes how to replace a button on the Server ribbon in Microsoft SharePoint Foundation.
Microsoft SharePoint Foundation 2010
SharePoint development tools in Microsoft Visual Studio 2010
To customize the ribbon, you start by creating an empty SharePoint project.

To create a SharePoint project

  1. Start Microsoft Visual Studio 2010.
  2. On the File menu, point to New, and then click Project.
  3. In Project Types, under Visual Basic or C#, select Empty SharePoint Project.
  4. Type ReplaceARibbonButton as the project name, and then click OK.
  5. In the SharePoint Customization Wizard, select Deploy as a sandboxed solution, and then click Finish.
You customize the ribbon by using a Feature. The following steps add a new Feature to your solution.

To add a new Feature

  1. In Solution Explorer, right-click Features and then click Add Feature.
  2. Change the Title of the Feature to Replace a Ribbon Button.
  3. In Solution Explorer, right-click Feature1, and then select Rename. Type ReplaceARibbonButton as the new name.
  4. In Solution Explorer, right-click the ReplaceARibbonButton project, and point to Add, and then select New Item.
  5. In the Add New Item dialog box, select the Empty Element template. Type ReplaceARibbonButton as the name.
You replace the ribbon button by using the Location attribute of the CommandUIDefinition element. The default values for ribbon buttons are listed in Default Server Ribbon Customization Locations. For an in-depth explanation of the ribbon XML, see Server Ribbon XML.

To define the custom action

  1. Open the Elements.xml file.
  2. Paste the following XML into the Elements.xml file. This XML replaces the Connect to Outlook button on the Library tab in the Connect & Export group for a document library.
    Important note Important
    You must replace the Image32by32 and Image16by16 attributes with valid image URLs.
    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction Id="Ribbon.Library.Actions.ReplacementButton"
        Location="CommandUI.Ribbon"
        RegistrationId="101"
        RegistrationType="List"
        Title="Replace a Ribbon Button">
        <CommandUIExtension>
          <CommandUIDefinitions>
            <CommandUIDefinition
              Location="Ribbon.Library.Actions.ConnectToClient">
                 <Button Id="Ribbon.Library.Actions.ConnectToClient.ReplacementButton"
                   Command="ReplacementButtonCommand"
                   Image16by16="Insert an image URL here."
                   Image32by32="Insert an image URL here."
                   LabelText="Replaced Button"
                   TemplateAlias="o2" />
            </CommandUIDefinition>
          </CommandUIDefinitions>
          <CommandUIHandlers>
            <CommandUIHandler
              Command="ReplacementButtonCommand"
              CommandAction="javascript:alert('This button has been replaced.');" />
          </CommandUIHandlers>
        </CommandUIExtension>
      </CustomAction>
    </Elements>
    
    
Because the project was set up as a sandboxed solution, it is deployed to the Solution Gallery.

To deploy the customization

  1. Press F5. The SharePoint development tools in Visual Studio 2010 automatically build and deploy the Feature.
  2. Navigate to a document library in your site or subsite.
  3. Click the Library tab, look in the Connect & Export group, and observe the absence of the Connect to Outlook button.
 

Using the SharePoint Foundation 2010 Managed Client Object Model refer to client object model gone through

 
 
 

No comments:

Post a Comment