Wednesday, December 10, 2014

Webparts Display in Tabs

<link  type="text/css" rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/themes/start/jquery-ui.css" />
<!-- Reference jQuery on the Google CDN -->
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<!-- Reference jQueryUI on the Google CDN -->
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>

<style type="text/css">
</style>

<script type="text/javascript">
     jQuery(document).ready(function($) {
         $(".s4-wpcell").hide();
         $(".s4-wpcell-plain").hide();
         //Put the Web Part Title for all the Web Parts you wish
         //to put into the tabbed view into the array below.
         setTimeout(function() {
            HillbillyTabs(["Announcements","News & Events","Industry News","Staff Updates"]);
        }, 0);

    });

function HillbillyTabs(webPartTitles)
    {
        for(index in webPartTitles)
        {
            var title = webPartTitles[index];
            $("#HillbillyTabs").append('<li><a href="#Tab'+index+'" id="TabHead'+index+'" onclick="SetActiveTab(this.id);">'+
title+'</a></li>').after('<div id="Tab'+index+'"></div>');
            $("span:contains('"+title+"')").each(function(){
                if ($(this).text() == title){
                   var webPart = $(this).hide().closest("span").closest("[id^='MSOZoneCell_WebPart']");
                   if ($(webPart).contents().html() != undefined)
                   {
                           webPart = $(webPart).contents();
                   }
                   $("#Tab" + index).append((webPart));
            }});
        }
        $("#tabsContainer").tabs();
        $(".s4-wpcell").show();
         $(".s4-wpcell-plain").show();

    }
</script>
<div id="tabsContainer"><ul id="HillbillyTabs"></ul></div>

Performing SharePoint Wizard in stand alone system

1. Open an Administrative command prompt. 
2. Change directory to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN 
3. Run PSConfig.exe -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures

Wednesday, September 10, 2014

Java Script: Enable/Disable Server controls based on DropDownValue.

   Java Script: Enable/Disable Server controls based on      
                           DropDownValue.
Client side and Sever side also word if changes in both the places



 <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>

<script type="text/javascript">
    $(document).ready(function () {

        //Attach change event hanlder to dropdownlist
        $("#<%=DropDown1.ClientID%>").change(function () {
            //check if selected value is not equal to
            if ($(this).val() == 'Yes') {
                //Hide the button
                $("#<%=tblName.ClientID%>").hide();
                $("#<%=tbPhone.ClientID%>").hide();

            }
            if ($(this).val() == 'No')
            {
                //show the button
                $("#<%=tblName.ClientID%>").show();
                $("#<%=tbPhone.ClientID%>").show();

            }
        });
               if ($('#<%=DropDown1.ClientID %> OPTION:selected').val() == 'Yes') {
            $("#<%=tblName.ClientID%>").hide();
            $("#<%=tbPhone.ClientID%>").hide();
        }
        else {
            $("#<%=tblName.ClientID%>").show();
            $("#<%=tbPhone.ClientID%>").show();
        }
    });

    </script>




 

Monday, September 1, 2014

Error: Unknown server tag "asp:ListView"

<%@ Register TagPrefix="asp" Namespace="System.Web.UI.WebControls" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>

Friday, August 22, 2014

Close SharePoint Popup Window on ASP.Net Button_Click


Close SharePoint Popup Window

Closes the Popup after your server side code executes.

            if (Page.IsPostBack)
            {
                string script = "<script language='javascript'>window.parent.location = window.parent.location; window.close();</script>";
                if (!this.Page.ClientScript.IsClientScriptBlockRegistered("rKey"))
                    this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "rKey", script);
            }


reff: http://antoniolanaro.blogspot.in/2011/04/open-sharepoint-2010-modal-dialog-and.html

Thursday, August 21, 2014

Ribbon Button with Popup Operations Model Dialogue

            Ribbon Button with Popup Operations Model Dialogue

Elements File
-----------------------------------------------------------------------------------------------------
  
  <CustomAction
    Id="DeleteRestoreCustomRibbonButton"
    RegistrationId="101"
    RegistrationType="List"
    Location="CommandUI.Ribbon"
    Sequence="5"
    Title="Delete/Restore"
     Rights="ManageLists" >

    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.Documents.Manage.Controls._children">
          <Button
              Id="Ribbon.DeleteRestoreButton"
              Alt="Delete/Restore"
              Sequence="5"
              Command="Rku_Test_Button"
              Image32by32="/_layouts/images/WinEarth32x32.png"
              Image16by16="/_layouts/images/WinEarth16x16.png"
              LabelText="Delete/Restore"
              TemplateAlias="o1" />
        </CommandUIDefinition>
      </CommandUIDefinitions>

      <CommandUIHandlers>
        <CommandUIHandler
          Command="Rku_Test_Button"
          CommandAction="javascript:
         
              function demoCallback(dialogResult, returnValue)
              {
                SP.UI.Notify.addNotification('Operation Successful!');
               
                SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
              }
             
              var ctx = SP.ClientContext.get_current();
              var items = SP.ListOperation.Selection.getSelectedItems(ctx);
              var myItems = '';
              var k;
             
              for (k in items)
              {
                myItems += '|' + items[k].id;
              }
             
              var options = {             
                url: '/_layouts/RKU/DeleteRestore.aspx?items=' + myItems + '&amp;source=' + SP.ListOperation.Selection.getSelectedList(),
                tite: 'Move Documents',
                allowMaximize: false,
                showClose: false,
                width: 680,
                height: 250,
                dialogReturnValueCallback: demoCallback };
             
              SP.UI.ModalDialog.showModalDialog(options);"
 
          //Single Item Section Enables the Button:

        EnabledScript="javascript:
        function enableBtn()
        {
        var context = SP.ClientContext.get_current();
        return SP.ListOperation.Selection.getSelectedItems(context).length == 1;
        }
        enableBtn();
        "
        />
      </CommandUIHandlers>

    </CommandUIExtension>
  </CustomAction>
 
  
  
---------------------------------------------------------------------------------------------------------------
Page:
====================
<table>
    <tr>
        <td>
            <asp:Label runat="server" ID="lblResoreSelect" Visible="false"><b>Restore Selected Document:</b></asp:Label>
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label runat="server" ID="lblDeleteSelect" Visible="false"><b>Delete Selected Document:</b></asp:Label>
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="lblSelectedItems" runat="server" Text=""></asp:Label>
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label for="Text" runat="server" ID="lblReason"><b>Please Select a Deletion Reason from the following:</b></asp:Label>
        </td>
    </tr>
    <tr>
        <td>
            <asp:RadioButtonList ID="radiBtnSelect" runat="server">
                <asp:ListItem>Duplicate of an existing document in the source</asp:ListItem>
                <asp:ListItem>Early draft or preliminary versions which have been transformed into a final document</asp:ListItem>
                <asp:ListItem>Notes and calculations of a minor or transitory nature used in preparation of more substantial document</asp:ListItem>
                <asp:ListItem>Non business document uploaded in error</asp:ListItem>
            </asp:RadioButtonList>
        </td>
    </tr>
    <tr>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
                ControlToValidate="radiBtnSelect" ErrorMessage="Please select a Deletion Reason"></asp:RequiredFieldValidator></td>
    </tr>
    <tr>
        <td>
            <asp:Button ID="btnOK" runat="server" Text="OK" OnClick="btnOK_Click" />
            &nbsp;<input id="btnCancel" type="button" value="Cancel" onclick="ClosePopup();" />

        </td>
    </tr>
</table>
<script type="text/javascript">

    function ClosePopup() {
        window.parent.location = window.parent.location; window.close();
    }

</script>



================================================================================


Page Load:
=========
  protected string OGDeteteRestoreLibrary = "GOADocs";
        protected System.Collections.Generic.List<SPListItem> ListItems;

        protected void Page_Load(object sender, EventArgs e)
        {
            // Close SharePoint Popup Window
            if (Page.IsPostBack)
            {
                string script = "<script language='javascript'>window.parent.location = window.parent.location; window.close();</script>";
                if (!this.Page.ClientScript.IsClientScriptBlockRegistered("rKey"))
                    this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "rKey", script);
            }

            if (Request.QueryString["items"] != null && Request.QueryString["source"] != null)
            {
                string source = Request.QueryString["source"];
                string[] items = Request.QueryString["items"].ToString().Split('|');

                source = source.Substring(1, source.Length - 2).ToLower();

                Guid sourceID = new Guid(source);

                SPDocumentLibrary sourceDocLib = (SPDocumentLibrary)SPContext.Current.Web.Lists[sourceID];

                ListItems = new System.Collections.Generic.List<SPListItem>();
                //
                for (int i = 1; i < items.Length; i++)
                {
                    SPListItem currentItem = sourceDocLib.GetItemById(int.Parse(items[i]));
                    SPListItem itemStatus = Web.Lists.TryGetList(OGDeteteRestoreLibrary).GetItemById(currentItem.ID);
                    if (itemStatus["Deleted"] != null && itemStatus["Deleted"].Equals("Deleted"))
                    {
                        // Restore Operation
                        lblResoreSelect.Visible = true;
                        radiBtnSelect.Visible = false;
                        lblReason.Visible = false;
                        SPListItem currentListItem = sourceDocLib.GetItemById(int.Parse(items[i]));
                        ListItems.Add(currentListItem);
                        lblSelectedItems.Text += currentListItem.Name + "<br>";
                    }
                    else
                    {
                        lblDeleteSelect.Visible = true;
                        SPListItem currentListItem = sourceDocLib.GetItemById(int.Parse(items[i]));
                        ListItems.Add(currentListItem);
                        lblSelectedItems.Text += currentListItem.Name + "<br>";
                    }
                    break;
                }

            }
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                if (Request.QueryString["items"] != null && Request.QueryString["source"] != null)
                {
                    string source = Request.QueryString["source"];
                    string[] items = Request.QueryString["items"].ToString().Split('|');

                    source = source.Substring(1, source.Length - 2).ToLower();

                    Guid sourceID = new Guid(source);

                    SPDocumentLibrary sourceDocLib = (SPDocumentLibrary)SPContext.Current.Web.Lists[sourceID];

                    ListItems = new System.Collections.Generic.List<SPListItem>();

                    for (int i = 1; i < items.Length; i++)
                    { // Delete Successfull
                        string siteURL = System.Web.HttpContext.Current.Request.Url.AbsoluteUri;
                        SPListItem currentListItem = sourceDocLib.GetItemById(int.Parse(items[i]));
                        SPListItem updateItem = Web.Lists.TryGetList(OGDeteteRestoreLibrary).GetItemById(currentListItem.ID);
                        if (updateItem["Deleted"] != null && updateItem["Deleted"].Equals("Deleted"))
                        { // Delete documets
                            btnOK.CausesValidation = false;
                            updateItem["Deleted"] = "";
                            updateItem.Update();

                            string script = "<script language='javascript'>window.close();</script>";
                            Page.ClientScript.RegisterClientScriptBlock(GetType(), "Register", script);

                        }
                        else
                        {  // Restore Successfull
                            updateItem["Deleted"] = "Deleted";

                            if (updateItem["Reasons_x0020_for_x0020_Delete"] == null)
                            {
                                updateItem["Reasons_x0020_for_x0020_Delete"] = radiBtnSelect.SelectedValue.ToString();
                            }
                            else
                            {
                                updateItem["Reasons_x0020_for_x0020_Delete"] = updateItem["Reasons_x0020_for_x0020_Delete"] + ". @:" + radiBtnSelect.SelectedValue.ToString();
                            }
                            btnOK.CausesValidation = false;
                            updateItem["Deleted"] = "Deleted";
                            updateItem["Deleted_x0020_Date"] = DateTime.Now;
                            updateItem["Deleted_x0020_By"] = Web.CurrentUser;
                            updateItem.Update();
                        }
                        break;
                    }
                }
            });
        }