1

I want to start development for SharePoint with JavaScript, but I am not sure if it provides the same flexibility as the server side development, for example I would like to make a web part with properties, that the web part can read these properties and do something with them, how would I do something like this without using custom web part? I am confused about if using custom web part means server side code or not.

3
  • It really depends on what you really mean by properties and custom web part. There are many out of the box web parts that have different options and properties. However, if you are trying to add javascript to a page, there are a few ways to do it. The most common is a Content Editor Webpart (CEWP). It also sounds like you are referring to having some form of properties that you want to be able to change, but not sure what you are asking there. You can create jQuery plugins that have different properties that you can use, but not sure if that was the angle you were thinking. Mar 17, 2014 at 23:56
  • Thanks for your answer. For example, in regular SP development, you can have a web part with properties that user can fill and then you read these properties. We do so by modifying the .cs file for the web part to add the new properties then read the properties in custom code. How do I do the same thing if I want to develop in JavaScript only solution? Is it clear? Mar 18, 2014 at 0:17
  • Yes, what eirikb states is correct, but you did not state that you were using 2013. Also, there is a big difference in the cloud version and on premise installs and between 2007, 2010, and 2013. In 2013 App model, there is a major difference in how things work and hosted apps in one of them. One of the major things I dislike about the whole thing is having to rebuild the UI and connect all your different pages together and all sorts of stuff because it doesn't run in the host web. There are ways to make things work, but it is a much different animal than on premise or farm/sandbox solutions. J Mar 18, 2014 at 8:03

1 Answer 1

2

If you are using SharePoint 2013 you can make a SharePoint hosted app which are JavaScript (and templates) only.
In those you can make a Client Web Part, and in these you can have custom properties, like this:

<Property 
    Name="name" 
    Type="string" 
    RequiresDesignerPermission="true" 
    DefaultValue="Friend" 
    WebCategory="Coffeemaker properties" 
    WebDisplayName="Your name, please."> 
</Property> 

ref http://code.msdn.microsoft.com/SharePoint-2013-App-part-9d83703c/sourcecode?fileId=60479&pathId=1470526092 (Coffeemaker app example)

3
  • Hi, Thanks a lot , that would really be helpful, but how can I make it for on premise as well? I need the same functionality as in Visual WebParts where I can have property and so on, but I don't really want to use custom code, I want to use only JS for it to be used in SPO as well Apr 3, 2014 at 1:46
  • A SharePoint hosted solution can be deploy on any 2013 SharePoint, such as on premise. Note that you need to enable apps on your site for it to work.
    – eirikb
    Apr 3, 2014 at 6:40
  • Can I use this method without needing to use Apps? for example if I need to make a visual web part for it. Apr 4, 2014 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.