Posts

Showing posts with the label SharePoint

Right way to add CSS and JavaScript to SharePoint App Pages and Master-Pages

In SharePoint-Hosted App, there is a special way to embed your JavaScript and CSS. Adding JavaScript: To add JavaScript that resides in the "layouts\15" folder, just specify the file name: < SharePoint:ScriptLink name=" sp.core.js " runat="server" LoadAfterUI="true" Localizable="false" /> To Add JavaScript that resides in your app, for example in "Scripts" folder of your SharePoint-Hosted App: <SharePoint:ScriptLink name=" ~site/Scripts/App.js " runat="server" OnDemand="false" LoadAfterUI="true" Localizable="false"></SharePoint:ScriptLink> Adding CSS: To add CSS to a SharePoint-Hosted App, you need to know how SharePoint works, its a bit different form that way JavaScript is embedded in the app. Initially I thought, I could use "<SharePoint:CssLink" just the way I used "<SharePoint:ScriptLink", but it wasn't true. Sha...

SharePoint 2013 Online and ASP.NET Web API using JSONP

Consider a scenario where you have to display data or make decisions on a SharePoint 2013 page based on the data that exists in a database. Here is what you can do: Abstract: 1. Create an Empty ASP.NET Web API project. 2. Enable the project for JSONP format 3. Add the Controller, Model, the business and data access logic to the service 4. Deploy the Service 5. Add script to SharePoint 2013 page Details: 1. Create an Empty ASP.NET Web API project. This is fairly simple step, all you need is MVC4 or above and .NET Framework 4.5. Using Visual Studio 2012/2013, Add new project, select an empty project and check the Web API box and click OK. 2. Enable the project for JSONP format: - Open package manager in visual studio (Tools&gt;NuGet Package Manager &gt; Package Manager Console and run the following command, it will add the required dlls to your project: Install-Package WebApiContrib.Formatting.Jsonp - In App_Start folder of the project, create a new class: ...