Create delegate control in sharepoint

Hello,
Today I am going to explain about creating delegate controls in sharepoint.
If you want to see any delegate controls you can visit in the master page. For publishing site there is nightandday.master page which is default master page for the home page of the site.
You can find the following delegate controls in the nightandday.master page.

<SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true"/>
<SharePoint:DelegateControl ControlId="GlobalSiteLink3-mini" Scope="Farm" runat="server"/>

Before moving to how to create a delegate control, first we look at what is the importance of delegate control.

Importance:

  • Using the delegate control a developer can customize the SharePoint site controls without editing or even touching the master page.
  • Suppose we created a control for displaying the advertisements in the master page. If we want to keep this control in the master page we need to edit that master page and add all the controls over here. At any time if any mistake happen then whole master page will disturb. To avoid this we have delegate controls.
  • Mapping the delegate control to master page
    After creating the delegate control now we want to add it to the master page. To do this we have one tag that is

    <SharePoint:DelegateControl runat="server" ControlId="" AllowMultipleControls=""/>

    ControlId –> is the Id of the control which we given in the elements.xml file while deploying the file. (Don’t worry at this time. We will cover in how to create delegate control in Visual Studio section)
    This is the main element for delegate control.

    Creating delegate control in Visual Studio
    Now I am creating a small control to enable a link for registering the new user in home page.
    To do this, you have to enable the forms based authentication. If you are not familiar to how to setup forms based authentication for sharepoint 2010 site then visit previous post.

  • After setting up the forms based authentication, open the visual studio and create an empty project.
  • Now add the control templates mapped folder, visual webpart, empty element like below image.
  • Now add the following code to the designer surface of the visual webpart
  • <div id="RegisterUserDiv" runat="server">
     <a href="#">Sample Delegate Control</a>
    </div>
    
  • In elements.xml file under the empty element you added, add the following code.
  • <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <Control Id="RegisterHereControl" Sequence="1000" ControlSrc="~/_controltemplates/RegisterUser.ascx" />
    </Elements>
    
  • Save the changes and deploy into the site.
  • Upto now we created a delegate control and deployed. Now we want to add it to our site. Now add the following code to our master page.
  • <SharePoint:DelegateControl ControlId="RegisterHereControl" AllowMultipleControls="true" runat="server"></SharePoint:DelegateControl>
    
  • It will look like this.
  • Advertisements

    What are ProcessImn() and ProcessImnMarkers() functions in sharepoint

    ProcessImn() and ProcessImnMarkers() are the functions which can be used to alert the sharepoint user for presence of active-x controls.
    These are used for displaing Active-X controls warning to the users.
    If we want to disable this we have to do some work around.
    The actual code will look like this in init.js file, which can be found in Templates\Layouts\1033

    function ProcessImn() 
    { 
        if (EnsureIMNControl() && IMNControlObj.PresenceEnabled) 
        { 
            imnElems=document.getElementsByName("imnmark"); 
            imnElemsCount=imnElems.length; 
            ProcessImnMarkers(); 
         } 
    }
    
    function ProcessImnMarkers() 
    { 
         for (i=0;i<imnMarkerBatchSize;++i) 
         { 
            if (imnCount==imnElemsCount) 
                return; 
            IMNRC(imnElems[imnCount].sip,imnElems[imnCount]); 
            imnCount++; 
          } 
          setTimeout("ProcessImnMarkers()",imnMarkerBatchDelay); 
    }
    

    If we develop any internet facing website and if we want to disable the message to the user for allow active-x controls then you have to comment all these lines.
    Now search for the function ProcessDefaultOnLoad() in the same file (init.js).
    Now comment the ProcessImn() function. Now execute. Warning will no more display.

    Reference from Microsoft

    Get List Items using Jquery in sharepoint

    Hello,

    Today I struggled a lot to find the solution to retrieve items from a list in sharepoint using jquery. Finally got solution.

    I have one List called City. It contains following fields.

    Image

    Now I want to retrieve items in this list into home page by using content editor webpart by using jquery. For this following are the steps.

    1. First link the jquery library and spservices library to your script file.

    2. Prepare a query based on the lists.asmx service for GetListItems function to get the data as per your requirement.

    3. Call the ajax function. Following is the entire code.

    <script type="text/javascript" src="_layouts/jquery-1.8.2.js"></script>
    <script type="text/javascript" src="_layouts/jquery.SPServices-0.7.1a.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
                    <soapenv:Body> \
                         <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                            <listName>City</listName> \
                            <viewFields> \
                                <ViewFields> \
                                   <FieldRef Name='Title' /> \
                               </ViewFields> \
                            </viewFields> \
                        </GetListItems> \
                    </soapenv:Body> \
                </soapenv:Envelope>";
            $.ajax({
                url: "http://sp2010:8080/personal/Inclusions/_vti_bin/lists.asmx",
                type: "POST",
                dataType: "xml",
                data: soapEnv,
                complete: processResult,
                error : callError,
                contentType: "text/xml; charset=\"utf-8\""
            });
        });
        function processResult(xData, status) {
        
            $(xData.responseXML).find("z\\:row").each(function() {
                var liHtml = "<li><a href='#'>" + $(this).attr("ows_Title") + "</a></li>";
                 $("#tasksUL").append(liHtml);
            });   }
        function callError(jqXHR, textStatus, errorThrown){   alert(errorThrown); }
    </script>
    </script>
    
        <marquee direction='up' behavior='scroll' style="height:100px" onmouseover= "this.stop();" onmouseout="this.start();"><ul id="tasksUL"/></marquee>
    
    

    4. Now upload this .js file into shared documents or any other documents list.

     

    5. Now link that .js file into content editor webpart as follows.

     

    6. Now click on ok. Now you can see in the content editor webpart the list items are scrolling(marquee effect). The useful area of this .js file is, to show the any upcoming events in home page. We dont need to go for visual studio to develop this. Just we should aware of  javascript and jquery.

    Glance at Search

    Search In sharepoint 2010

    What we can search in sharepoint?

    Following is answer

    1. Structured information
    • List Data
    • Line of business
    • User profiles
    2. Unstructured information
    • Documents
    • Website
    • Exchange
    • Lotus notes

    Sharepoint foundation 2010 gives

    • Basic search within site collections
    • No external data sources
    • Simple and automatic configuration

    Search Server express 2010

    • Installable on SPF2010
    • Search center for multiple content sources
    • External content sources
    • Single application server.

    Search Server 2010

    • Same as Search server express 2010 but allows scalability and redundancy with multiple application servers

    Sharepoint Server 2010

    • Same as search server 2010
    • People search supports user profiles and my sites
    • Faceted search with managed metadata(refinements).
    • Allows multi tenant hosting environments.

    Fast Search server 2010 for sharepoint

    • Maximum scalability
    • More customization options for user experience
    • Improved support for multimedia and video support
    • Sophisticated and customizable content processing engine.

    What’s new in 2010 regarding search:

    • Search center improvements
    • Revamped architecture as service application.
    • Managed metadata search refinement
    • Mobile search
    • Integration with windows desktop search
    • More powerful query syntax.
    • Improved relevancy formulas with click through relevancy.
    • Improved administration
    • Monitoring and reporting

    There are three search centers available in sharepoint 2010.

    1. Basic search center

    2. Enterprise search center (Sharepoint server publishing infrastructure must be activated)

    3. Fast search center (Sharepoint server publishing infrastructure must be activated)