Monday, November 19, 2012

Simple jQuery Tabbing with Time interval

Hi Friends,

I thought to share simple things more frequently and occasionally post more detail findings (since we are on war to fight with time :) )

If your div structure is below:

<body onload="javascript:TabInterval();">

<div id="div1">
<p>This is Div 1</p>
</div>
<div id="div2" style="display: none;">
<p>This is Div 2</p>
</div>
<div id="div3" style="display: none;">
<p>This is Div 3</p>
</div>

</body>

We can simply rotate these divs using .show() and .hide() methods

So, Try with below jQuery script

<script type="text/javascript">
//starting point for the rotation, after initially load div 1  
var startRootDiv = 2;
    function rotateAllDivs() {
        if (startRootDiv == 2) {
            $("#tab1").hide();
            $("#tab2").show();
            startRootDiv = 3;
        }
        else if (startRootDiv  == 3) {

            $("#tab2").hide();
            $("#tab3").show();           

            startRootDiv = 1;
        }
        else {

            $("#tab1").show();
            $("#tab3").hide();           

            startRootDiv = 2;
        }
    }
    function TabInterval() {
        setInterval(rotateAllDivs, 5000);
    };
</script>

This div tabbing configured to run with a time interval of 5 seconds.

Happy simple coding :)

Buddike

Wednesday, November 7, 2012

Trying to use an SPWeb object that has been closed or disposed and is no longer valid.

Hi Guys,

You may have faced this kind of error while coding the webparts and provisioning them in SharePoint pages. May be you will face this issue while trying to edit a page, that having the webpart with below code

using(SPWeb web = SPContext.Current.Web)
{
//Your code here
}

Issue is with using statement, its disposing your SPWeb object automatically when you leaving using block. Use below than the above block

SPWeb web = SPContext.Current.Web

Hope you will figure it out within your code.

Happy coding guys,

Buddike

Thursday, November 1, 2012

SharePoint Search Refinement Panel

Hi Guys,

You may like to learn more about search refinement panel and how to use it.

Scenario:

Think that your client have several departments and each department having seperate documents to be use. Each department is a site collection and these specific documents residing in a document library called "Department Docs". So client asking for search refinement to implement.

My steps will be like below:

1.Create a Site column for holding departments, type : choices
2.Check the Document library residing in side the department site collection
3.Add the column to the default view of the document library
4.Add several documents to the library
5.Do a incremental crawl to the content source, through Central Admin-> Application Management -> Search Application-> Content Source
6.Wait till crawl completes
7.Create Managed Meta Data property
8.Do a full crawl
9.Create a Enterprise Search Centre page
10.Modify the page and Edit Refinement Panel webpart
11. Modify below category markup and save the webpart

<Category Title="Departments" Description="Departments docs" Type="Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator" MetadataThreshold="0" NumberOfFiltersToDisplay="3" MaxNumberOfFilters="20" ShowMoreLink="True" MappedProperty="Departments" MoreLinkText="show more" LessLinkText="show fewer" />


Note:
Title: appear in the refinement panel
MetadataThreshhold : if your department column having metadata this is the minimum value to use when displaying the results
MappedProperty : This is the Field name you have used to create the managed metadata.
12.Checkin the page
13.Run a search...There you can find the refinement values you have just configured.

I'll update this post with more screens, while time permits

Happy coding,

Buddike