Archive for ‘Web Parts’

April 3, 2013

SharePoint 2010 – Search Core Results XSLT Transformation

Suddenly your manger says to you, man, we just wanted to modify the core search results of the SharePoint 2010. So the first step is to add a Search core results web part to your search results page and open the same page in a browser. After that put the page in edit mode and choose edit web part from the Search Core Results Web Part menu.

In the Search Core Results Tool Pane open the Display Properties section and then uncheck “Use Location Visualization” and you can notice that the XSL Editor… button should become active.

image001

Click the “XSL Editor…” button to open the Text Editor dialog.

image002

Replace all the above XSL with the below (or just copy to the clipboard hence you will need the data in future):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xmp><xsl:copy-of select="*"/></xmp>
</xsl:template>
</xsl:stylesheet>

The reason why I did substituted the existing XSLT is to know how the SharePoint renders the output of the search results.

So the core results search of the SharePoint will give you the results in a format as below:

<All_Results>
    <Result>
      <id>1</id>
      <workid></workid>
      <rank>1006</rank>
      <title>Your document title</title>
      <author>Mikael Svenson</author>
      <size>79872</size>
      <path>http://server/path/test.html</path>
      <description></description>
      <write>11/1/2010</write>
      <sitename>Procedures</sitename>
      <collapsingstatus></collapsingstatus>
      <hithighlightedsummary>This is a summary.</hithighlightedsummary>
      <hithighlightedproperties>
        <HHTitle>Your document title</HHTitle>
        <HHUrl>http://server/path/test.html</HHUrl>
      </hithighlightedproperties>
      <imageurl imageurldescription="Web Page">/_layouts/images/html16.png</imageurl>
      <contentclass></contentclass>
      <isdocument>True</isdocument>
      <picturethumbnailurl></picturethumbnailurl>
      <url>http://server/path/test.html</url>
      <serverredirectedurl></serverredirectedurl>
      <fileextension>ASPX</fileextension>
      <spsiteurl></spsiteurl>
      <docvector>[procedure overview, 1][links, 0.707107]</docvector>
      <fcocount>1</fcocount>
      <fcoid>336059505871761914</fcoid>
      <pictureheight></pictureheight>
      <picturewidth></picturewidth>
      <escbaseextension>xls</escbaseextension>
      <escprojname>00 - UNDEFINED</escprojname>
      <escdeptname>0000 - UNDEFINED</escdeptname>
      <escprocnumber></escprocnumber>
      <esccategoryname>COMPANY MANAGEMENT SYSTEM</esccategoryname>
      <escsubcategoryname>GOVERNING DOCUMENTS</escsubcategoryname>
      <eschistdocnum></eschistdocnum>
    </Result>
</All_Results>

When you wanted to modify the search results, then what you have to do is to modify the XSLT part that we copied in one of the steps above. I usually used to do is to copy all those XSLT in to Visual Studio and then modifying the same as needed.

image004

By default the search results would be as below with icons, etc.

image006

After modifying the XSLT the search results would like below:

image008

I was using the OOB search paging web part to get the paging for the search results.

image010

please refer the following links for more detail:

Enterprise Search Core Results XSLT Transformation
http://msdn.microsoft.com/en-us/library/ms584121%28v=office.12%29.aspx

How to: View Search Results XML Data
http://msdn.microsoft.com/en-us/library/ms546985.aspx

Take Control of Search XSL
http://www.ableblue.com/blog/archive/2011/09/30/take-control-of-search-xsl/

Advertisements
January 10, 2013

Branding the Sharepoint 2010 Top Navigation

IF anyone interested in doing the branding the top navigation of the sharepoint site, just start it with this link.

before branding the Top Navigation:

beforebranding

After branding the Top Navigation:

afterbranding
The above mentioned SharePoint top navigation had to support variation with the Arabic fonts. So i had issues when the top navigation turns its direction to RTL. so the solution mentioned in the below link helped me out to find the problem which made the menu to behave naughty.

http://social.msdn.microsoft.com/Forums/da-DK/sharepointcustomizationprevious/thread/7f2b6811-1d19-4a9c-a5fa-29f5be4dbe5a

the problem which i was getting is from the following style in core4.css
.menu ul.dynamic {
position: absolute;
right: -999em;
}

Had to override the style which was mentioned in the core4.css with the below entry:

.menu ul.dynamic {
position: absolute!important;
top: -999em!important;
}

refer the following link to start up the branding:

http://chrisstahl.wordpress.com/2010/11/04/customizing-sharepoint-2010-global-navigation-with-css-and-jquery-2/

apart from the branding of the top navigation had to brand the search OOB webpart. You can find the style which i used in the below css style.

before branding the search OOB webpart:

searchbefore

after branding the search OOB webpart:

searchafterbranding
As well as if you need to hide the breadscrumb (sitemap path navigation) of the site please add the following entry in the master page or in a content editor web part on the page. (just check the ID of the control when browsing the page).

<style type=”text/css”>

#ctl00_PlaceHolderTitleBreadcrumb_ContentMap {display=none;}

</style>

the complete style sheet:

/* Drop Down: Container Style */
.s4-tn ul.dynamic{
background-color:rgb(65, 64, 66)!important;
border:thin rgb(182, 164, 85) double !important;
border: thick #b6a455 double!important;

}
/* Drop Down: Item Padding Style */
.s4-tn li.dynamic > .menu-item{
/*padding:10px 20px 10px 20px;*/
}
/* Drop Down: Hyperlink Styles */
.s4-tn li.dynamic > a{
font-size: 9px!important;
font-weight:normal!important;
color:#b6a455!important;
border:thin rgb(182, 164, 85) double!important;
text-align:left;
}
/* Drop Down: Hyperlink Hover Style */
.s4-tn li.dynamic > a:hover{
background-color:rgb(182, 164, 85)!important;
color:rgb(65, 64, 66)!important;
border: thin rgb(65, 64, 66) double!important;
}

/*          top menu */
/* Drop Down: Hyperlink static style */
.s4-tn li.static > .menu-item {
font-size: 9px!important;
font-weight:normal!important;
color:#b6a455!important;
border:thin rgb(182, 164, 85) double !important;
background-color:rgb(65, 64, 66);
border: thick #b6a455 double!important;
}
/* Drop Down: Hyperlink static Hover Style */
.s4-tn li.static > a:hover{
background-color:rgb(182, 164, 85)!important;
color:rgb(65, 64, 66)!important;
border: thick rgb(65, 64, 66) double!important;
}
/* Drop Down: Hyperlink static Hover Style */
.s4-tn li.static > a.selected{
background-color:rgb(182, 164, 85)!important;
color:rgb(65, 64, 66)!important;
border: thick rgb(65, 64, 66) double!important;
}
/* top down menu */
.menu-horizontal a.dynamic-children span.additional-background, .menu-horizontal span.dynamic-children span.additional-background
{
background-image:none!important;
}
.menu-horizontal ul.dynamic a.dynamic-children span.additional-background, .menu-horizontal ul.dynamic span.dynamic-children span.additional-background
{
background-image:url(“/Style Library/Images/Arrow_English.gif”)!important;
}
.menu-vertical a.dynamic-children span.additional-background, .menu-vertical span.dynamic-children span.additional-background{
background-image:url(“/Style Library/Images/Arrow_English.gif”)!important;
}

/* Search Box */

.s4-search input.ms-sbplain {
width: 220px !important;
line-height: 20px !important;
height:17px!important;
background-color: #F5EFE0 !important;
border: 1px solid #D3AE81 !important;
}
.s4-search .ms-sbgo {
padding: 0;
margin: 0;
line-height: 20px;
text-align:center!important;
vertical-align:middle!important;
}
.s4-search .ms-sbgo a {
background-image: url(‘/Style Library/Images/Search_en.gif’);
background-repeat: no-repeat;
width: 120px;
height: 33px;
display: block;
text-align:center;
vertical-align:middle;
margin-left:10px;
margin-top:5px;
}
.s4-search .srch-gosearchimg {
display: none;
}
.ms-sbscopes {
display: none;
}
td.ms-sbcell{
background-color:rgb(182, 164, 85)!important;
border:0px;
text-align:center;
vertical-align:middle;
}
.ms-sbtable{
border-top-width:0px!important;
border-right-width:0px!important;
border-bottom-width:0px!important;
border-left-width:0px!important;
background-color:white!important;
border-top-style:none!important;
border-right-style:none!important;
border-bottom-style:none!important;
border-left-style:none!important;
border-bottom-color:rgb(182, 164, 85)!important;
border-top-color:rgb(182, 164, 85)!important;
border-right-color:rgb(182, 164, 85)!important;
border-left-color:rgb(182, 164, 85)!important;
}
.ms-sbLastcell{
display:none;
}
.search .ms-sbcell{
color:#4f4f4f!important;
}
.menu-horizontal li.static, .menu-horizontal a.static, .menu-horizontal span.static{
float:none!important;
display:inline-block!important;
}

April 6, 2012

Session state can only be used when enableSessionState is set to true

Today i was working with a sharepoint visual webpart and was trying to add some data in to session and was getting the error : {System.Web.HttpException: Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration>\<system.web>\<httpModules> section in the application configuration.
at System.Web.UI.Page.get_Session()
at inc_coe_forms.ContactUs.ContactUsUserControl.btnAddMoreFiles_Click(Object sender, EventArgs e)}

Or

Unexpected error occurred: System.Web.HttpException: Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \\ section in the application configuration.
Solution

Usually Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive.

configuration file

<pages enableSessionState="true" >
<httpModules>
 <add type="System.Web.SessionState.SessionStateModule" name="Session" />
 </httpModules>

Page directive

<%@ Page Language="C#" enableSessionState="true"%>

This happens when IIS is not configured properly after creating SharePoint application and there are web parts or features that use session you may get the above error.

You can enable the session state in IIS when you followed step as below:


January 13, 2010

Adding SQL Server Reporting Services Report Viewer Web Part – SharePoint

Once i have installed the Reporting Services add in for the SharePoint by default the SQL Server Reporting Services Report Viewer web part should be enabled in SharePoint web part library. But in my case it was not added and listed in the library. So i had to add it manually.

follow the steps as below:

clip_image002

clip_image004

clip_image006

clip_image008

clip_image010

After adding the web part to your page just configure the same to view your report.

clip_image012

you can download the addin from the following link:

http://www.microsoft.com/downloads/details.aspx?familyid=1E53F882-0C16-4847-B331-132274AE8C84&displaylang=en

March 5, 2009

How To Debug WebParts in VS 2008

If we need to debug a WebPart which is being integrated into Sharepoint Website then have to modify the existing values in web.config as below :

<customErrors mode=“Off” />

<compilation batch=”false” debug=”true“>

Once the web.config is updated then you can directly set a breakpoint in your webpart source code and can debug in a Visual Studio environment.

1. Open your web part solution in VS 2008
2. Open Moss site or Web part page in a IE (Web Browser)
3. Place a Breakpoint in your code
4. Select Attach to Process from the DEBUG menu from the VS.
5. From the available process list select “w3wp.exe” & click on attached button.