My team mate Neal posted this easy article about creating a Visual WebPart. Enjoy!
SharePoint - Tech Bytes: SharePoint 2010 - Creating a Visual Webpart: Overview Visual webparts wraps asp.net user control inside a classic webpart, so that programmer could work on ascx file as for any other ...
Wednesday, October 30, 2013
Thursday, October 17, 2013
Friday, October 4, 2013
User Profile Properties through JSOM
Following is the code to get the current user's Profile Properties through JSOM (JavaScript Object Model) in SharePoint 2013.
<script src="/_layouts/15/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="/_layouts/15/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/_layouts/15/init.js" type="text/javascript"></script>
<script src="/_layouts/15/sp.runtime.js" type="text/javascript"></script>
<script src="/_layouts/15/sp.js" type="text/javascript"></script>
<script src="/_layouts/15/SP.UserProfiles.js" type="text/javascript"></script>
<script type="text/javascript">
//$(document).ready(function(){
SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, 'SP.UserProfiles.js');
//});
var userProfileProperties;
function getUserProperties() {
var clientContext = new SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
userProfileProperties = peopleManager.getMyProperties();
clientContext.load(userProfileProperties);
clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);
}
// This function runs if the executeQueryAsync call succeeds.
function onRequestSuccess() {
var messageText = "<b>";
if (userProfileProperties.get_userProfileProperties()['Title'] != "")
messageText += userProfileProperties.get_userProfileProperties()['Title'];
if (userProfileProperties.get_userProfileProperties()['SPS-Department'] != "")
messageText += ", " + userProfileProperties.get_userProfileProperties()['SPS-Department'];
if (messageText.length > 5)
messageText += "<br/>";
if (userProfileProperties.get_userProfileProperties()['Office'] != "")
messageText += userProfileProperties.get_userProfileProperties()['Office'];
if (userProfileProperties.get_userProfileProperties()['WorkPhone'] != "")
messageText += ", " + userProfileProperties.get_userProfileProperties()['WorkPhone'];
messageText += "</b>";
$get("results").innerHTML = messageText;
}
// This function runs if the executeQueryAsync call fails.
function onRequestFail(sender, args) {
$get("results").innerHTML = "Error: " + args.get_message();
}
</script>
<div id="results"></div>
Wednesday, September 25, 2013
Modifying the Display Template for People Search Results
I was working on HTML for displaying people search results and found a very decent article about creating/modifying the Item_Person.htm template.
http://social.technet.microsoft.com/Forums/sharepoint/en-US/90ae7c55-63fc-4f8c-b77b-6ca3846e9610/how-to-create-a-display-template-for-people-search-results
What is a Display Template?
Check here: http://mysplist.blogspot.com/2013/09/display-templates-for-search-result-web.html
http://social.technet.microsoft.com/Forums/sharepoint/en-US/90ae7c55-63fc-4f8c-b77b-6ca3846e9610/how-to-create-a-display-template-for-people-search-results
What is a Display Template?
Check here: http://mysplist.blogspot.com/2013/09/display-templates-for-search-result-web.html
Tuesday, September 24, 2013
Display Templates for Search Result Web Part
A very nice article on Display Templates for Search Result Web Part for SharePoint 2013.
http://blogs.technet.com/b/sharepoint_quick_reads/archive/2013/08/01/sharepoint-2013-customize-display-template-for-content-by-search-web-part-cswp-part-1.aspx
http://blogs.technet.com/b/sharepoint_quick_reads/archive/2013/08/01/sharepoint-2013-customize-display-template-for-content-by-search-web-part-cswp-part-1.aspx
Tuesday, September 10, 2013
Adding Java Script File Reference to Head Tag from WebPart
Scenario:
In my recent web part development project, I had to include a custom java script and css file for the UI of the web part. Now, I was writing all the C# code in CreateChildControl so reference to js file comes in the Body tag of the rendered HTML page. Ideally all the references to js and css should render inside the Head tag.
Solution: In CreateChildControl function, use following code:
Solution: In CreateChildControl function, use following code:
using System.Web.UI.HtmlControls;
HtmlGenericControl MyJS = new HtmlGenericControl("script");
MyJS.Attributes.Add("type", "text/javascript");
MyJS.Attributes.Add("src", "/_layouts/15/scripts/Mobile_Custom.js");
Page.Header.Controls.Add(MyJS);
HtmlGenericControl MyCSS = new HtmlGenericControl("link");
MyCSS.Attributes.Add("rel", "stylesheet");
MyCSS.Attributes.Add("href", "/_layouts/15/Styles/Mobile_Custom.css");
Page.Header.Controls.Add(MyCSS);
Wednesday, August 7, 2013
SAML 2.0 Authentication
Recently I have been working on a project where one of our web part needs to use a third party API/services which requires SAML authentication.
Thought to make notes here how the SAML 2.0 authentication works. Here is a very good diagram from Google that explains what is the flow of authentication:
Thought to make notes here how the SAML 2.0 authentication works. Here is a very good diagram from Google that explains what is the flow of authentication:
Subscribe to:
Posts (Atom)
-
Scenario: Updating the Master Page for SharePoint Online is not recommended by Microsoft now.....fine. So how do we change the UI then? And...
-
Microsoft introduced Office Graph a couple of months back which uses machine learning techniques to connect people to the relevant content,...
-
Recently my customers was looking for a solution where on-field guys can search for answers related to their tasks and it was a perfect scen...
Official SharePoint Documentation
I have recently contributed to the official SharePoint documentation for developement. Check it out here: https://docs.microsoft.com/en-us...
