SharePoint 2013 Manage Services link missing
I noticed “Manage Services on Server” link is missing from Central Administration, I know it should be there under System Settings.
After google, I found its a common issue most users have and solution is “Try running IE with elevated privileges, (run as administrator)”
How to Log Errors in SharePoint Hosted Apps?
It is most common thing to log error message if some exception occurs within the code, so that user can find out what causing the error. It is straight forward if you using Server side object model. Since Hosted apps only use JavaScript object model and its bit new to many of us, not sure which namespace/class to use.
We use SP.Utilities.Utility.logCustomAppError method to log the app errors. Following is the sample code
function onFail(sender, args) {
logAppError(args.get_message() + '\n' + args.get_stackTrace());
}
function logAppError(message) {
SP.Utilities.Utility.logCustomAppError(context, message);
this.context.executeQueryAsync();
}
SharePoint 2013 App Model – How to View list With in APP
If you working on SharePoint 2013 APP, at some point you defiantly want to see list items contained within the app. Unfortunately there is no navigation to traverse to list.
To view specific list in “APP Web”, you directly type the url which specified in the following format in browser
http://<APP WEB URL>/<APP NAME>/Lists/<List Name>/AllItems.aspx
Ex: http://app-0eb6021fad963e.apps.com/sites/SP2K13/WhiteCaseEDARAPP/Lists/Calendar/AllItems.aspx
If in case you want to see the List settings,
- Click “Modify View” under List tab
- Click on “Settings” link as shown below
Get Public Key Token From Visual Studio
To add a command within Visual Studio
- Got to Tools and then select External Tools
- Click Add Button
- Name it what ever you want, I name it “Get SN Token”
- on Command text, select following location
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\sn.exe
- On Arguments, type following
-Tp $(TargetPath)
Could not find UpdatePanel with ID 'XXXX'. If it is being updated dynamically then it must be inside another UpdatePanel
I working on a project where I need to create a connected web parts in SharePoint. I created these web parts and wrap it in update panels. Also I am using the exception handling, so that if any error occurs in the code, I just clearing all the controls in the update panel and created a label control to show detailed error message. Everything works normally (update contents in each web part) if I do not get any error.
But if I get any error in the code, exception shows without any JavaScript error when page loads. Next I made some changes in the filters and hit submit button, now I am getting the JavaScript error as shown below.
Could not find UpdatePanel with ID 'ctl00_m_g_bcc7da50_1d6b_4979_8186_4246cbd7ca34_udpItemListingWebPart'. If it is being updated dynamically then it must be inside another UpdatePanel
I couldn’t figure it out what was causing this error for couple of hours. I know there is some thing wrong with the update panel and I closely look into the error message. Since error message says “It is being updated dynamically” and I changed the UpdateMode to “Conditional”.
Now It’s working without any JavaScript error. :)
SharePoint DateTime Control Date Format
If you are working with DateTime Control in SharePoint, you might have a requirement to show date format (For example DD/MM/YYYY) based on the user regional setting instead of US date format (MM/DD/YYYY)
You can specify the regional settings locale id to DateTime local id on Page Load
int localId = Convert.ToInt32(SPContext.Current.RegionalSettings.LocaleId);
dtpcStartDate.LocaleId = localId;
If you want to change the default date format, no matter what the user regional setting is, you can do it my writing the custom control by deriving from the Microsoft.SharePoint.WebControls.DateTimeControl.
public class CustomDatePicker : Microsoft.SharePoint.WebControls.DateTimeControl
{
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
TextBox tb= (TextBox)this.Controls[0];
DateTime dt = DateTime.Parse(tb.Text);
tb.Text = dt.ToString("dd/MM/yyyy");
}
}
}
Note: For above code, I used the Autopostback = true to trigger OnPreRender event until i figure it out how to trigger onDateChangeed event client side.
How to show dates which has TBD at the end of the SharePoint List?
I am working on the two custom web parts, one of them is filter web part and another one is a results web part which shows data filtered from the SharePoint list based on the user selection. In the filter web part, we have a date range where they can specify certain range or just leave it empty so that we just return records which are greater than or equal to current date. Since dates are not mandatory in my SharePoint list (user don’t have a date and it is TBD – to be decided), it either shows empty dates at the top if i order by dates in ascending order without any filter criteria or it won’t show empty dates if i apply filter criteria.
But my requirement is,
- we should show empty dates (TBD)
- TBD should be at the end of the result set and not in the beginning of the result set.
To implement this, we created a calculated field and use the following formula
=IF(ISBLANK(DateColumn),DATE(2099,1,1),DateColumn)
Where
DateColumn – is a column we used to store the user selected date in the List.
Above formula we used max date (01/01/2099), so that we can easily use “Greater than or equal to” to compare with other dates and also sort dates in ascending order so that max dates will so at the end.
In the results web part, we are using XSLT to show the data and in that we are checking dateColumn empty or not, if empty show TBD or else show actual date.
Hope this helps some one and have a happy programming.
Connected Web Part Approaches
I found a very nice article about Connected web parts.
No Edit Page Option in Site Actions in MOSS 2007
Today I tried to Edit the Form pages to add Web Parts, for somehow, i Couldn’t see the option under Site Actions. I found a short cut to edit the page using ?ToolPaneView=2.
For Eg: http://SHAREPOINTSITE/Lists/Test List/NewForm.aspx?ToolPaneView=2
Navigate to Web Part Maintenance Page in SharePoint
As most of you know that there are two options to remove web parts from a SharePoint page.
- Close – preserves the web part’s configurations and customizations in Closed Web Parts gallery.
- Delete – deletes permanently.
If you want to see list of all closed web parts on the page, you have to go to Web part maintenance page. However, there is no easy way to get to this page.
A quick way to navigate to Web Part maintenance page in both SharePoint 2007 and SharePoint 2010
Option 1:
Copy the following code in browser and make changes accordingly,
http://[SERVERNAME]/_layouts/spcontnt.aspx?pageview=shared&url=[Your Web Part Page URL] (For Example: /FirmCalendar/pages/default.aspx)
Option 2: (Much easier)
Just append the querystring “?Contents=1” to any page that contains Web parts as shown below,
http://[SERVERNAME]/default.aspx?contents=1
Note: In SharePoint Server 2010, a closed Web part no longer consumes the system resources as open Web parts do.
Error occurred in deployment step 'Add Solution': Exception from HRESULT: 0x81070215
Here I got another error which won’t tell about what the error is. so, i went to SharePoint root folder (14 hive) and checked the log file. Log file contains the following error message
Failed to open the file 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features\WebGTSTemplates\GTSProjectTemplate\onet.xml'.
I Checked the ONET.xml file properties and i found that i forgot to change the Deployment Type to Element File. Once i changed, now i am able to deploy my feature successfully.
Hope this helps some one’s life easier. If so, leave some comments.
Fix Disabled Page Scrolling on Navigation Settings
I don’t know how many of you having issues with Master page branding, i got lot of them and one of them was Navigation (AreaNavigationSettings.aspx) page. When the page renders/load in the browser, it disables the scrollbar even though it has content more than the viewable area and other pages are just fine.
After struggling long time to find out the cause, i couldn’t find any. So, my next option is to search in Google and see any one has similar issue. Likely i found the article from SharePoint Blues which addressing about this issue.
They mentioned about the following workaround which won’t fix the disabled scroll bars instead it hides the #s4-workspace scrollbar (Which is OOB) and shows the browser scrollbar.
$(document).ready(function() {
$('form[action="AreaNavigationSettings.aspx"]')
.closest('body')
.css('overflow', 'visible')
.find('#s4-workspace')
.css('overflow', 'hidden');
});
Error occurred in deployment step 'Add Solution': Exception from HRESULT: 0x8107026E
I got the following error when i deploying my custom web template in SharePoint 2010 environment.
After hours of troubleshooting, i figure it out that WebTemplate Name in the elements.xml has to match with the web template project name. See the highlighted section in the following screenshot. I hope this post will help someone and if so don’t forgot to leave a comment.
IE6 Tooltip for Select element workaround
In my project, we have a requirement to show huge list of data in a select element. Some of these data has long names to show but the restriction what we have is, Select element has to be in a fixed width to fit it in our UI. So to accomplish the requirement we have the following options
Option 1: Show Horizontal and vertical scroll bars so that user scrolls to see the full name.
Option 2: Show full name in a tooltip on mouse over.
Option 1 is not a good choice to me since it has scroll bars which spoils UI look and feel. Even though i tried this option and later i found that Select element won’t have any horizontal scroll bar by default in IE6 (Bug). Later i found that they have workaround to achieve this functionality.
I googled lot for option 2 and found couple of solutions, but it worked partially. so i made the couple of changes to fit my needs. Following is the code i used for IE6 tooltip.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>IE6 Hack to enable tooltips on select elements</title>
<script>
function showIE6Tooltip(obj, e)
{
if (!e)
{
e = window.event;
}
var eX = e.offsetX ? e.offsetX : e.layerX;
var eY = e.offsetY ? e.offsetY : e.layerY;
var maxOptionCount = obj.options.length;
var listItemHeight = (obj.clientHeight / obj.size);
var itemsAtTheTop = Math.floor(obj.scrollTop / listItemHeight);
var hoverOptionIndex = Math.floor(eY / listItemHeight);
//the index of mouseover
var toolTipIndex = Math.floor(hoverOptionIndex + itemsAtTheTop);
if(hoverOptionIndex >= 0 && hoverOptionIndex < obj.size )
{
var tooltip = document.getElementById('ie6SelectTooltip');
tooltip.innerHTML = obj.options[toolTipIndex].text;
mouseX=e.pageX?e.pageX:e.clientX;
mouseY=e.pageY?e.pageY:e.clientY;
tooltip.style.left=mouseX+10;
tooltip.style.top=mouseY;
tooltip.style.display = 'block';
var frm = document.getElementById('frm');
frm.style.left = tooltip.style.left;
frm.style.top = tooltip.style.top;
frm.style.height = tooltip.offsetHeight;
frm.style.width = tooltip.offsetWidth;
frm.style.display = 'block';
}
else
{
hideIE6Tooltip(e);
}
}
function hideIE6Tooltip(e)
{
var tooltip = document.getElementById('ie6SelectTooltip');
var iFrm = document.getElementById('frm');
tooltip.innerHTML = '';
tooltip.style.display = 'none';
iFrm.style.display = 'none';
}
</script>
</head>
<body>
<div style="overflow-x:hidden; overflow-y:scroll; height:200px; width:90px">
<select id="test" title="Title on the select" onmousemove="showIE6Tooltip(this,event);" onmouseout="hideIE6Tooltip();" size="20" >
<option value="1" title="This is the number 1 option, with a really long title based tooltip">1 Thing</option>
<option value="2" title="This is the number 2 option, with a really long title based tooltip">2 Thing</option>
<option value="3" title="This is the number 3 option, with a really long title based tooltip">3 Thing</option>
<option value="4" title="This is the number 4 option, with a really long title based tooltip">4 Thing</option>
<option value="5" title="This is the number 5 option, with a really long title based tooltip">5 Thing</option>
<option value="6" title="This is the number 6 option, with a really long title based tooltip">6 Thing</option>
<option value="7" title="This is the number 7 option, with a really long title based tooltip">7 Thing</option>
<option value="8" title="This is the number 8 option, with a really long title based tooltip">8 Thing</option>
<option value="9" title="This is the number 9 option, with a really long title based tooltip">9 Thing</option>
<option value="10" title="This is the number 10 option, with a really long title based tooltip">10 Thing</option>
<option value="11" title="This is the number 11 option, with a really long title based tooltip">11 Thing</option>
<option value="12" title="This is the number 12 option, with a really long title based tooltip">12 Thing</option>
<option value="13" title="This is the number 13 option, with a really long title based tooltip">13 Thing</option>
<option value="14" title="This is the number 14 option, with a really long title based tooltip">14 Thing</option>
<option value="15" title="This is the number 15 option, with a really long title based tooltip">15 Thing</option>
<option value="16" title="This is the number 16 option, with a really long title based tooltip">16 Thing</option>
<option value="17" title="This is the number 17 option, with a really long title based tooltip">17 Thing</option>
<option value="18" title="This is the number 18 option, with a really long title based tooltip">18 Thing</option>
<option value="19" title="This is the number 19 option, with a really long title based tooltip">19 Thing</option>
<option value="20" title="This is the number 20 option, with a really long title based tooltip">20 Thing</option>
</select>
</div>
<div id="ie6SelectTooltip" style="display: none; position: absolute; padding: 1px; border: 1px solid #333333;
background-color: #fffedf; font-size: smaller; z-index: 999;">
</div>
<iframe id="frm" style="display: none; position: absolute; z-index: 998"></iframe>
</body>
</html>
For me the above code worked vary well. I hope this code is useful for some one. If so, please leave some comments below.
Enable AJAX Support in SharePoint,WSS, MOSS 2007
Microsoft suggests the following changes to web.config for your SharePoint installation if you want to enable AJAX functionality. http://msdn.microsoft.com/en-us/library/bb861898.aspx
I found the this file ( http://www.hansrasmussen.com/2010/02/enable-ajax-support-in-sharepointwss-moss-2007/ ) which enable AJAX support in MOSS 2007 using Feature.
SharePoint DateTimeControl returns today's date if there is no selected date
By Default SharePoint DateTimeControl returns today's date if there is no selected date. Use IsDateEmpty to check whether user selected any date or not. If IsDateEmpty returns true, means no date selected by the user otherwise user selected the date and use that date.
if (!((DateTimeControl)c).IsDateEmpty)
{
columnValue = ((DateTimeControl)c).SelectedDate.ToString();
}
else
{
columnValue = "";
}
Internet Explorer JavaScript Debugging
Most of the time people frustrated with JavaScript errors since the lack of information provided by the browser. You can use alert’s to find out where it went wrong but this is annoying by number of clicks. So you have to use some debugging tools for browser.
If you are a .NET Developer, Visual Studio comes with inbuilt JavaScript debugging tool. But what if you are neither a .NET developer nor you have Visual Studio. In this case Microsoft provides a free tool called “Microsoft Script Debugger” which you can download it from here. As of i know, this is the free and best tool for debugging JavaScript on Internet Explorer.
To use either Visual Studio or Microsoft Script Debugger as your debugging tool, you have to turn debugging on in IE. To do that Go to Tools –> Internet Options –> Advanced tab. Make sure that “Disable Script debugging (Internet Explorer)” is not checked.
Once you restart the browser, you can load your page which you want to test it. If there are any errors on the page, it shows a Dialog box asking whether to debug or not and just press OK button. That’s it. Now you can see where exactly the error happens and analyze accordingly.
If in case you want to debug specific line irrespective of error. You can put a line debugger; in your JavaScript code. so it will create a break point automatically and when this breakpoint gets hit, your debugger will lunch.
Hope this helps some one.
Event manager error: Could not load file or assembly
Blog Editors
Before you leave:
- Tell me whether you like this article or not? Rate this post accordingly by selecting the stars below.
- Any suggestion, question or comment? Please post it in the comments below.
How to find duplicate records in SQL Server?
This is not a tuff job to do but recently one my friend asked me the same question and i replied with the following query.
SELECT SKUID, COUNT(SKUID) FROM SKURequests
GROUP BY SKUID
HAVING COUNT(SKUID) > 1
Even though it is very simple, i thought to share in my blog so it may help some one who needs it.