May 26, 2013

Code blocks are not allowed in this file.

In Moss 2007 or SharePoint 2010, most of the times we need to create the custom master pages. In order to perform certain actions/functions, we need to insert code within those master pages.

Main problem comes into arena, when we try to use upload that master page into the master page gallery or copying into the file system, and use as system master page or site master page. Since the custom master page contains code with in it, so we used to get the below screen.

In order to solve this problem, we need to make entries into the corresponding web.config file by following the below steps.

1) Go to corresponding web.config file location which is located at the below location ( under c drive)


2) Open the web.config file , and under the <SafeMode><PageParserPaths> tag make the below entries.

< PageParserPath VirtualPath="/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true"/>


VirtualPath attribute should contains location where the master page is located. "/*" at the end of the /_catalogs/masterpage" in the virtual path attribute indicates to also include the subfolders.

Window could not start the SharePoint 2010 Timer service on Local Computer.

In SharePoint 2010, while starting the SharePoint 2010 Timer service, we get Error 1069 : The service did not start due to a logon failure like the below screen.



The main cause of this problem is that password of the account under which the SharePoint 2010 Timer service is running has been changed. So, we need to update this password in SharePoint 2010 Timer properties.

Steps to update password for timer service

1) Right click the SharePoint 2010 Timer service > properties

2) Click on Log On tab and enter password under This account option.


3) Click apply > Ok > restart the SharePoint 2010 Timer service.
 
 
 

 
 



 

May 19, 2013

This page allows a limit of 200 controls, and that limit has been exceeded.

In Moss/Sharepoint, some while playing with placeholders in the master pages we face the error like the below screen.

 

The above screen shows that the number of placeholders that can be included in a master page has been exceeded.

Solution

The solution for the above problem is that either
1) To remove placeholders from the master page or
2) (Best One) Increase the value of the MaxControls attribute in the web.config of the corresponding web application as highlighted below.



 

April 17, 2013

Align inner div at center of outer div

While development you must have noticed that <div> tags are used more frequently in all programming languages. So, it is easier to align one <table><tr><td> at center of anothet <table><tr><td>.

But to align, one div at center of another div, we can use style's margin attribute like below.

<Div style="width:100%">
       <Div style="width:50%;margin:0 auto">
            Inner div at center of outer div
       </Div>
</Div>

November 4, 2012

Activating Publishing Infrastructure Feature

To make a site publishing type, we need to activate "Office SharePoint Server Publishing Infrastructure". Sometimes, activating Office SharePoint Server Publishing Infrastructure feature on a site collection throws error. There are two ways to activate the same feature. 

1) Clicking on Activate button in feature gallery and
2) By using stsadm commands.

To activate  publishing infrastructure feature through commands, use the below commands:

stsadm -o activatefeature -filename publishing\feature.xml -url http://sitecollectionurl -force

stsadm -o activatefeature -filename publishingresources\feature.xml -url
http://sitecollectionurl -force

stsadm -o activatefeature -filename publishingSite\feature.xml -url
http://sitecollectionurl -force

stsadm -o activatefeature -filename publishingweb\feature.xml -url
http://sitecollectionurl -force

stsadm -o activatefeature -filename publishinglayouts\feature.xml -url
http://sitecollectionurl -force

stsadm -o activatefeature -filename navigation\feature.xml -url
http://sitecollectionurl -force


October 15, 2012

Extracting DLL from assembly

Sometimes, based on the requirements , we get into a situation when we want to extract DLL's from assembly. In direct words, it is not possible to drag-drop the DLL's from the assembly folder which is generally located at C:\windows\assembly location.

So, extract the dll from assembly folder, perform these steps

1) Click Start > Run.
2) In Run window, enter "C:\windows\assembly\gac" without quotes and press enter.
3) The window that open, contains dll's in folder, which you can easily copy or drag-drop.


August 12, 2012

Searching Document or Form Library items using JQuery

JQuery plays an important role in the Sharepoint or you can say, web development. It will sound interesting to you that we can use the jquery even for searching items from a document, form or images library. 

I have used the jquery , found on the "Sharepoint Kings Blog" ( thanx for sharing this jquery), with the custom searching scope to search the items from a particular document library.

To implement the jquery for searching, we need to do the following steps:
1) Create custom search scope.
2) Create webpart page.
3) Adding CEWP (content editor webpart) and pasting the jquery in source editor tab.
4) Changing the Scope attribute to the custom new scope (if required).

So, to create the custom scopes,
1) Go to Site Actions > Site Settings
2) Under Site Collection Administration > Search Scopes
3) On next page, click New Scope
4) Click OK.

After creating the custom scope, we need to add rules to the custom scopes. On the view scopes page, click Add Rules, next to the newly created search scope.

1) In Scope Rule Type, Select the Web Address option.
2) In Web Address, Select Folder and enter the url of the library from which you want to search the items( you can create the rules as per your requirement).
3) In Behaviour, Select Require.
4) Click OK.


Now, you are done with creating custom search scope and rules. Its time to add the CEWP. Edit the page where you want to display the search results and add CEWP. In the source editor button, paste the below Jquery and update the following
1)url of the  jquery-1.3.2.min.js file (at the top of the jquery).
2) update the Scope with the name of the new custom search scope under "Customizable parameters ".

<script type="text/javascript" src="/_LAYOUTS/1033/jquery-1.3.2.min.js"></script>
<script type="text/javascript">


// *** Customizable parameters ***

var quickSearchConfig = {
delay: 500, // time to wait before executing the query (in ms)
minCharacters: 3, // minimum nr of characters to enter before search
scope: "CustomSearchScopeName", // search scope to use
numberOfResults: 75, // number of results to show
resultsAnimation: 200, // animation time (in ms) of the search results
resultAnimation: 0 // animation time (in ms) of individual result (when selected)
};
</script>

<style type="text/css">

.quickSearchResultDivUnselected
{
background: white;
border: 1px solid white;
margin-left: 2px;
overflow: hidden;
text-overflow: ellipsis;
}
.quickSearchResultDivSelected
{
background: #EEEEEE;
border: 1px solid Gray;
margin-left: 2px;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
<table id="quickSearchTable" class="ms-sbtable ms-sbtable-ex" border="0" style="width:50%">
<tbody>
<tr class="ms-sbrow">
<td class="ms-sbcell">
<input style="width: 50%" id="quickSearchTextBox" class="ms-sbplain" title="Enter search words"
style="width: 170px" alt="Enter search words" maxlength="200" value="" />
</td>
<td class="ms-sbgo ms-sbcell" style="width: 14px">
<img title="Go Search" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px;
border-right-width: 0px" alt="Go Search" src="/_layouts/images/gosearch.gif" />
</td>
<td style="width: 1px">
</td>
</tr>
</tbody>
</table>
<div id="quickSearchResults" style="display: none;">
</div>

<script type="text/javascript">

var quickSearchTimer;
var quickSearchSelectedDivIndex = -1;

function showResultsDiv(text) {

var div = $("#quickSearchResults");
var prevTable = div.prev();

var divCss = {

"left": prevTable.offset().left,
"padding": 2,
"position": "absolute",
"top": prevTable.offset().top + prevTable.height() + 1,
"border": "1px solid #7f9db9",
"width": prevTable.width() - 3,
"background": "white",
"max-width": prevTable.width() - 3
};

div.css(divCss).append(text).slideDown(quickSearchConfig.resultsAnimation);

}

$(document).ready(function() {

$('#quickSearchTextBox').keyup(function(event) {
var previousSelected = quickSearchSelectedDivIndex;

// catch some keys

switch(event.keyCode) {
case 13: // enter
var selectedDiv = $("#quickSearchResults>div:eq(" + quickSearchSelectedDivIndex + ") a");
if(selectedDiv.length == 1)
window.location = selectedDiv.attr("href");
break;
case 38: // key up
quickSearchSelectedDivIndex--;
break;
case 40: // key down
quickSearchSelectedDivIndex ++;
break;
}

// check bounds

if(quickSearchSelectedDivIndex != previousSelected) {
if(quickSearchSelectedDivIndex < 0)
quickSearchSelectedDivIndex = 0;
if(quickSearchSelectedDivIndex >= $("#quickSearchResults>div").length -1)
quickSearchSelectedDivIndex = $("#quickSearchResults>div").length - 2;
}

// select new div, unselect the previous selected

if(quickSearchSelectedDivIndex > -1) {
if(quickSearchSelectedDivIndex != previousSelected) {
unSelectDiv( $("#quickSearchResults>div:eq(" + previousSelected + ")"));
selectDiv($("#quickSearchResults>div:eq(" + quickSearchSelectedDivIndex + ")"));
}
}

// if the query is different from the previous one, search again

if($('#quickSearchTextBox').data("query") != $('#quickSearchTextBox').val()) {
if (quickSearchTimer != null) // cancel the delayed event
clearTimeout(quickSearchTimer);
quickSearchTimer = setTimeout(function() { // delay the searching
$("#quickSearchResults").fadeOut(200, initSearch);
} , quickSearchConfig.delay);
}
});
});

function unSelectDiv(div) {

// first stop all animations still in progress
$("#quickSearchResults>div>div").stop(true,true);

div.removeClass("quickSearchResultDivSelected").addClass("quickSearchResultDivUnselected");

$("#details", div).hide();
}

function selectDiv(div) {

div.addClass("quickSearchResultDivSelected");
$("#details", div).slideDown(quickSearchConfig.resultAnimation);
}

function initSearch() {

// first store query in data
$('#quickSearchTextBox').data("query", $('#quickSearchTextBox').val());

// clear the results

$("#quickSearchResults").empty();

// start the search

var query = $("#quickSearchTextBox").val();
if(query.length >= quickSearchConfig.minCharacters) {
showResultsDiv("Searching ..."); // display status
search(query);
}
}

function search(query) {

quickSearchSelectedDivIndex = -1;
var queryXML =
"<QueryPacket xmlns='urn:Microsoft.Search.Query' Revision='1000'> \
<Query domain='QDomain'> \
<SupportedFormats><Format>urn:Microsoft.Search.Response.Document.Document</Format></SupportedFormats> \
<Context> \
<QueryText language='en-US' type='STRING' >SCOPE:\"" + quickSearchConfig.scope + "\"" + query + "</QueryText> \
</Context> \
<SortByProperties><SortByProperty name='Rank' direction='Descending' order='1'/></SortByProperties> \
<Range><StartAt>1</StartAt><Count>" + quickSearchConfig.numberOfResults + "</Count></Range> \
<EnableStemming>false</EnableStemming> \
<TrimDuplicates>true</TrimDuplicates> \
<IgnoreAllNoiseQuery>true</IgnoreAllNoiseQuery> \
<ImplicitAndBehavior>true</ImplicitAndBehavior> \
<IncludeRelevanceResults>true</IncludeRelevanceResults> \
<IncludeSpecialTermResults>true</IncludeSpecialTermResults> \
<IncludeHighConfidenceResults>true</IncludeHighConfidenceResults> \
</Query></QueryPacket>";

var soapEnv =

"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> \
<soap:Body> \
<Query xmlns='urn:Microsoft.Search'> \
<queryXml>" + escapeHTML(queryXML) + "</queryXml> \
</Query> \
</soap:Body> \
</soap:Envelope>";

$.ajax({

url: "/_vti_bin/search.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
contentType: "text/xml; charset=\"utf-8\""
});

function processResult(xData, status) {

var html = "";
$(xData.responseXML).find("QueryResult").each(function() {
var divWidh = $("#quickSearchTable").width() - 13;

var x = $("<xml>" + $(this).text() + "</xml>");

x.find("Document").each(function() {
var title = $("Title", $(this)).text();
var url = $("Action>LinkUrl", $(this)).text();
var description = $("Description", $(this)).text()

html +=

"<div class='quickSearchResultDivUnselected' style='width:" + divWidh + "px;max-width:" + divWidh +"px'> \
<a href='" + url + "'>" + $("Title", $(this)).text() + "</a> \
<div style='display:none' id='details' style='margin-left:10px'>"
+ description +
"<br/>" + url + " \
</div> \
</div>";
});
if(x.find("TotalAvailable").text() != "")
html += "<div style='text-align:right'>Total results: " + x.find("TotalAvailable").text() + "</div>";
else
html += "<div style='text-align:right'>Total results: 0</div>";
});

$("#quickSearchResults").empty().append(html);

$("#quickSearchResults>div>a").hover(
function() { selectDiv($(this).parent()); },
function() { unSelectDiv($(this).parent()); }
);
showResultsDiv();
}
}

function escapeHTML (str) {

return str.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
}
</script>


Save the page.


 Now, enter the string into the text box and your search result will display like the below image.




Error installing .Net Framework 3.5 in Sql Server 2012

During installation of Sql Server 2012 on Windows server 2012 or addition of roles and features for SharePoint 2013, the setup wizard will...