Recently I have to display client info on a page. I have two options, either with webpart (server side control) or use script editor webpart (client object modal).
Here is the script i use:
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script type="text/javascript">
var userid= _spPageContextInfo.userId;
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";
var requestHeaders = { "accept" : "application/json;odata=verbose" };
$.ajax({
url : requestUri,
contentType : "application/json;odata=verbose",
headers : requestHeaders,
success : onSuccess,
error : onError
});
function onSuccess(data, request){
var Logg = data.d;
document.getElementById('welcomediv').innerHTML="Hello, "+Logg.Title;
document.getElementsByTagName('title')[0].innerHTML='Home';
}
function onError(error) {
alert("error");
}
</script>
If you want Site Name, Here is the code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () { SP.SOD.executeFunc('sp.js', 'SP.ClientContext', getWebProperties); $('.userprofilpic').hide();});
function getWebProperties() {
var ctx = new SP.ClientContext.get_current();
this.web = ctx.get_web();
ctx.load(this.web,'Title');
ctx.executeQueryAsync(Function.createDelegate(this, this.onSuccess),
Function.createDelegate(this, this.onFail));
}
function onSuccess(sender, args) {
document.getElementById('welcomediv').innerHTML="Site Name: "+this.web.get_title();
}
function onFail(sender, args) {
alert('failed to get list. Error:'+args.get_message());
}
</script>
That's it for now.
Tuesday, 30 December 2014
Wednesday, 3 December 2014
"Sign in as Different User" in SharePoint 2013
One of features used in testing of permissions in SharePoint is "Sign in as Different User" which allows you to log in as an another user. With SharePoint 2013 this option is missing.
To get this feature back follow the following steps :
1. Locate and then open the following file in a text editor:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES\Welcome.ascx
2.Add the following element before the existing "ID_RequestAccess" element:
<SharePoint:MenuItemTemplate runat="server" ID="ID_LoginAsDifferentUser" Text="<%$Resources:wss,personalactions_loginasdifferentuser%>" Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>" MenuGroupId="100" Sequence="100" UseShortId="true" />
3.Save the file.
To get this feature back follow the following steps :
1. Locate and then open the following file in a text editor:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES\Welcome.ascx
2.Add the following element before the existing "ID_RequestAccess" element:
<SharePoint:MenuItemTemplate runat="server" ID="ID_LoginAsDifferentUser" Text="<%$Resources:wss,personalactions_loginasdifferentuser%>" Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>" MenuGroupId="100" Sequence="100" UseShortId="true" />
3.Save the file.
Thursday, 27 November 2014
Get Site Template GUID using Powershell
Sometimes we need to find the GUID of save site template.
Open Power shell management shell in administrator mode.
here is the power shell script that provide you the functionality. pate it.
$url = "http://localhost:mysite/"
$site= new-Object Microsoft.SharePoint.SPSite($url )
$loc= [System.Int32]::Parse(1033)
$templates= $site.GetWebTemplates($loc)
foreach ($child in $templates){ write-host $child.Name " " $child.Title}
click Enter. And you will get the list of site template with the GUID.
Enjoy
Open Power shell management shell in administrator mode.
here is the power shell script that provide you the functionality. pate it.
$url = "http://localhost:mysite/"
$site= new-Object Microsoft.SharePoint.SPSite($url )
$loc= [System.Int32]::Parse(1033)
$templates= $site.GetWebTemplates($loc)
foreach ($child in $templates){ write-host $child.Name " " $child.Title}
click Enter. And you will get the list of site template with the GUID.
Enjoy
Friday, 21 November 2014
How to delete the unused application pool From IIS?
Recently I had issue with user profile service. I delete it and try to recreate it. That time I got an error
"
So I search for the resolution of the issue. I got two options
1. They say Try a different name. - Which didn't help in my case.I would say try your luck also.
2. Delete current app pool and try again to create.
So here is the process:
IIS will not provide the interface for managing service application's application pools. But we can delete service application's application pool in SharePoint 2010/2013 using powershell.
Use these below cmd-let to get list of service application's application pools.
Get-SPServiceApplicationPool
SharePoint 2010/2013 delete orphaned application pool: To delete a application pool of service application, use the cmdlet:
Remove-SPServiceApplicationPool
"
An object of the type Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool named "User Profile Service App Pool" already exists under the parent Microsoft.SharePoint.Administration.SPIisWebServiceSettings named "SharePoint Web Services". Rename your object or delete the existing object.
". So I search for the resolution of the issue. I got two options
1. They say Try a different name. - Which didn't help in my case.I would say try your luck also.
2. Delete current app pool and try again to create.
So here is the process:
IIS will not provide the interface for managing service application's application pools. But we can delete service application's application pool in SharePoint 2010/2013 using powershell.
Use these below cmd-let to get list of service application's application pools.
Get-SPServiceApplicationPool
SharePoint 2010/2013 delete orphaned application pool: To delete a application pool of service application, use the cmdlet:
Remove-SPServiceApplicationPool
1. Run "Sharepoint Management Shell " in administrator mode.
2. Type "Get-SPServiceApplicationPool". It will give you list of app pool.
3. Type "Remove-SPServiceApplicationPool".
4. It will ask you identity. Give the app pool name you want to remove from above list. Try not to make spell mistake.
5. Click Enter.
6.It will ask for confirmation. Type "y". click Enter.
Enjoy.
2. Type "Get-SPServiceApplicationPool". It will give you list of app pool.
3. Type "Remove-SPServiceApplicationPool".
4. It will ask you identity. Give the app pool name you want to remove from above list. Try not to make spell mistake.
5. Click Enter.
6.It will ask for confirmation. Type "y". click Enter.
Enjoy.
Original source: http://www.sharepointdiary.com/2011/02/how-to-delete-service-application-app-pool.html#ixzz3JgnQWkc1
Thursday, 20 November 2014
Linq query to datatable conversion
Recently I have encounter with Linq after a long time and I was required to convert linq result in to datatable. It take a while but I found the method i used in past. I hope it will help you too.
1. use AsEnumerable() in your query.and you will be good to get a function CopyToDataTable() to get datatable.
Example:
{
if (query == null)
{
throw new ArgumentNullException("query");
}
IDbCommand cmd = ctx.GetCommand(query as IQueryable);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = (SqlCommand)cmd;
DataTable dt = new DataTable("sd");
try
{
cmd.Connection.Open();
adapter.FillSchema(dt, SchemaType.Source);
adapter.Fill(dt);
}
finally
{
cmd.Connection.Close();
}
return dt;
}
For getting datatable
var vr = from country in objDataContext.CountryMaster
select new {country.CID,country.CName};
DataTable dt = ToDataTable(objDataContext,vr);
Original source : http://www.c-sharpcorner.com/uploadfile/VIMAL.LAKHERA/convert-a-linq-query-resultset-to-a-datatable/
1. use AsEnumerable() in your query.and you will be good to get a function CopyToDataTable() to get datatable.
Example:
var query = from order in orders.AsEnumerable() join detail in details.AsEnumerable() on order.Field<int>("SalesOrderID") equals detail.Field<int>("SalesOrderID") where order.Field<bool>("OnlineOrderFlag") == true && order.Field<DateTime>("OrderDate").Month == 8 select new { SalesOrderID = order.Field<int>("SalesOrderID"), SalesOrderDetailID = detail.Field<int>("SalesOrderDetailID"), OrderDate = order.Field<DateTime>("OrderDate"), ProductID = detail.Field<int>("ProductID") }; DataTable orderTable = query.CopyToDataTable();
Original Source : http://msdn.microsoft.com/en-us/library/bb386921%28v=vs.110%29.aspx
2. use this coustom method to get datatable
Example:public DataTable ToDataTable(System.Data.Linq.DataContext ctx, object query)
{
if (query == null)
{
throw new ArgumentNullException("query");
}
IDbCommand cmd = ctx.GetCommand(query as IQueryable);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = (SqlCommand)cmd;
DataTable dt = new DataTable("sd");
try
{
cmd.Connection.Open();
adapter.FillSchema(dt, SchemaType.Source);
adapter.Fill(dt);
}
finally
{
cmd.Connection.Close();
}
return dt;
}
For getting datatable
var vr = from country in objDataContext.CountryMaster
select new {country.CID,country.CName};
DataTable dt = ToDataTable(objDataContext,vr);
Original source : http://www.c-sharpcorner.com/uploadfile/VIMAL.LAKHERA/convert-a-linq-query-resultset-to-a-datatable/
Monday, 17 November 2014
On-screen Keyboard in Windows
Sometimes soon we will have a touchscreen desktops in our work premises. If you want a on screen keyboard here are some shortcuts
1.
Click the Start menu, point to All Programs, point to Accessories, point to Accessibility, and then click On-Screen Keyboard to open On-Screen Keyboard.
(link - http://windows.microsoft.com/en-IN/windows-xp/help/on-screen-keyboard)
2. My way start -> run -> type "osk". click ok. you can create shortcut on desktop writing osk in shotcut. and click on it.
Enjoy.
1.
Click the Start menu, point to All Programs, point to Accessories, point to Accessibility, and then click On-Screen Keyboard to open On-Screen Keyboard.
(link - http://windows.microsoft.com/en-IN/windows-xp/help/on-screen-keyboard)
2. My way start -> run -> type "osk". click ok. you can create shortcut on desktop writing osk in shotcut. and click on it.
Enjoy.
Monday, 6 October 2014
Free Operating Systems
Worried about licence OS?
Feel free of licence Microsoft OS and use this Linux based operating systems.
I have some free os name and their sites where you can download it.
No 5 PC-BSD9 : HTTP://www.pcbsd.org/
No 4 ArchBang Linux : HTTP://archbang.org/
No 3 Zorin OS 5 : HTTP://zorin-os.com/index.html
No 2 CrunchBang : HTTP://crunchbanglinux.org/
No 1 Puppy Linux : HTTP://puppylinux.org
No 0 startos: HTTP://www.startos.org/
Enjoy.
Feel free of licence Microsoft OS and use this Linux based operating systems.
I have some free os name and their sites where you can download it.
No 5 PC-BSD9 : HTTP://www.pcbsd.org/
No 4 ArchBang Linux : HTTP://archbang.org/
No 3 Zorin OS 5 : HTTP://zorin-os.com/index.html
No 2 CrunchBang : HTTP://crunchbanglinux.org/
No 1 Puppy Linux : HTTP://puppylinux.org
No 0 startos: HTTP://www.startos.org/
Enjoy.
Tuesday, 30 September 2014
Play any video in HTML in IE.
"Play any kind of video ".
I was working on IE-8. Here is the code I use to integrate video in my page.
Example:
<html>
<body>
<link href="//releases.flowplayer.org/5.5.0/skin/minimalist.css" rel="stylesheet"></link>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//releases.flowplayer.org/5.5.0/flowplayer.min.js"></script>
<div class="flowplayer">
<video>
<source src="http://www.W3Schools.com/tags/movie.mp4" type="video/mp4"></source>
</video>
</div>
</body>
</html>
I was working on IE-8. Here is the code I use to integrate video in my page.
Example:
<html>
<body>
<link href="//releases.flowplayer.org/5.5.0/skin/minimalist.css" rel="stylesheet"></link>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//releases.flowplayer.org/5.5.0/flowplayer.min.js"></script>
<div class="flowplayer">
<video>
<source src="http://www.W3Schools.com/tags/movie.mp4" type="video/mp4"></source>
</video>
</div>
</body>
</html>
Friday, 12 September 2014
Error occurred in deployment step 'Retract Solution': The language-neutral solution package was not found.
I was working on one project when i got this error while deployment and i have Google it. I found some solution which are as below
- Close Visual Studio Solution and completely exit out of it, then run it again and compile. This sometimes fixes the issue.
- Right-Click on your Visual Studio Solution, select "Clean" Solution, then Right Click on SharePoint Project and choose "Retract". Rebuild and Deploy.
- In PowerShell running as Administrator run Uninstall-SPSolution:
- Unistall-SPSolution -identity {Name of WSP File} -allwebapplications
- In PowerShell running as Administrator run Remove-SPSolution: Remove-SPSolution -identity {Name of WSP File} -force
- In PowerShell running as Administrator run the Delete() command: (Get-SPSolution {Name of WSP File}).Delete()
Original Source : language-neutral-solution-package-Error
But In My problem I do not Find WSP to uninstall. so what to do in such condition:
Just Follow this step:
- Open Your solution and Publish the Project. This will create wsp in Bin folder of your project.
- Open cmd in Administrator mode and enter this path; cd C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\
- Then type following command to add wsp : stsadm -o addsolution -filename <path of .wsp file>.
- Then type following command to add wsp : stsadm -o deploysolution -name <name of .wsp file> -url <site url> - immediate -allowgacdeployment -force.
this work for me. when i deploy again it run as smoothly as it could.
Thursday, 11 September 2014
javascript keypress event
Sometimes we need to handle enter key event on textbox. For that we can use fiollowing code
$('#myInput').keypress(function(event) {
if (event.keyCode == 13) {
alert('Entered'); // write your code here
}
});
myInput : textbox/ input control id
event.keyCode : The e key value you needed.
Here are some key values:
$('#myInput').keypress(function(event) {
if (event.keyCode == 13) {
alert('Entered'); // write your code here
}
});
myInput : textbox/ input control id
event.keyCode : The e key value you needed.
Here are some key values:
|
|
|
Subscribe to:
Posts (Atom)
SharePoint Classic Site Retirement: Your Plan to Avoid Last-Minute Chaos
Classic SharePoint has been on borrowed time for years. Microsoft has now put dates on the remaining pieces. Microsoft will disable creation...
-
In last blog we learn how can we enable footer on SharePoint Online Modern Communication site. If you have not gone through that you can use...
-
If you're managing SharePoint Online environments, there's a significant change on the horizon that you need to prepare for. Microso...
-
Issue : Recently, we had a requirement to sync the calendar between shared mailbox outlook and SharePoint Calendar list. We have created 2 f...