lørdag den 7. juli 2012
SharePoint 2013
I was at 7 days training in next version of SharePoint back in February 2012. I was privileged to learn from Ted Pattison, Andrew Connell, Steve Peschka, Scot Hillier, Baer, and dear Luca and Vesa. After the traing, I got to work on two SharePoint 2013 projects.
My SharePoint 2013 blog
fredag den 30. marts 2012
JavaScript - Client Object Model - C#
When I started working with SharePoint back in 2004, it didn't take me long time to realize that you can code everything in C# on a SharePoint project, but it was far more easier, faster, and the performance was much better, if you minimized trips to the server and didn't use back-end code.
Realizing the power of JavaScript was easy, but working with JavaScript was not. Sure, it was easy to find JavaScript code that you can use in your project, but I missed that fine feeling of working with Visual Studio and writing C# code.
I like nice things, I like to draw and paint (things I draw aren't pretty, but I like it). I also think that nicely done user interface is used and appreciated more than the "ugly" one. For many years, I had a feeling that most of the time, I used JavaScript to create fancy pop ups and roll ups in SharePoint - things that, in my mind are a bit superficial. Not like C# code that "does" something important. Serious stuff. For many years, JavaScript for me was something I could copy/paste wherever and whenever it was needed. I felt that I didn't really have to concentrate on writing it, because it was just JavaScript. I kind of hated the fact that I spent so much time learning the OOP and C#, and I was earning money, and paying my bills with copy/pasting. I also didn't like the fact that I could paste that JavaScript code wherever I wanted - in the web part, on the page, on the master page, and it would work. No rules, no governance, no fancy tools, just Notepad.
Many years after, I realized that many of the developers couldn't just figure out how to "copy/paste". It seams that it is more difficult to comprehend than C# code. JavaScript don't work whenever and wherever.
Last year, I worked on two intranet portals, where SharePoint COM with JavaScript was the only way of going forward. Sure, I could just tell the customer that it's not possible to code and bla blah, blah. What do they know :-)
But, I decided to try it out - that new thing, the COM with JavaScript, because COM allows you to "do" something with JavaScript. You can get content from lists, write to lists, manage columns, and so on. I also decided to make a JavaScript library for the project, and web parts that reference the .js files, so I don't have JavaScript scattered to the four winds.
The project turned out very good and the customers are very fond of it. What can I say, JavaScript is not the same as it used to be, and I'm very close to loving it.
Realizing the power of JavaScript was easy, but working with JavaScript was not. Sure, it was easy to find JavaScript code that you can use in your project, but I missed that fine feeling of working with Visual Studio and writing C# code.
I like nice things, I like to draw and paint (things I draw aren't pretty, but I like it). I also think that nicely done user interface is used and appreciated more than the "ugly" one. For many years, I had a feeling that most of the time, I used JavaScript to create fancy pop ups and roll ups in SharePoint - things that, in my mind are a bit superficial. Not like C# code that "does" something important. Serious stuff. For many years, JavaScript for me was something I could copy/paste wherever and whenever it was needed. I felt that I didn't really have to concentrate on writing it, because it was just JavaScript. I kind of hated the fact that I spent so much time learning the OOP and C#, and I was earning money, and paying my bills with copy/pasting. I also didn't like the fact that I could paste that JavaScript code wherever I wanted - in the web part, on the page, on the master page, and it would work. No rules, no governance, no fancy tools, just Notepad.
Many years after, I realized that many of the developers couldn't just figure out how to "copy/paste". It seams that it is more difficult to comprehend than C# code. JavaScript don't work whenever and wherever.
Last year, I worked on two intranet portals, where SharePoint COM with JavaScript was the only way of going forward. Sure, I could just tell the customer that it's not possible to code and bla blah, blah. What do they know :-)
But, I decided to try it out - that new thing, the COM with JavaScript, because COM allows you to "do" something with JavaScript. You can get content from lists, write to lists, manage columns, and so on. I also decided to make a JavaScript library for the project, and web parts that reference the .js files, so I don't have JavaScript scattered to the four winds.
The project turned out very good and the customers are very fond of it. What can I say, JavaScript is not the same as it used to be, and I'm very close to loving it.
onsdag den 28. marts 2012
JavaScript - Client Object Model - Basics
//Get current context
var ctx = new SP.ClientContext.get_current();
//Get other site (web) context
var ctx = new SP.ClientContext("/othersite/");
//Get web
var web = ctx.get_web();
//Get current page ID in Pages library
var pageID = SP.PageContextInfo.get_pageItemId();
//Get current user
var user = ctx.get_web().get_currentUser();
user.retrieve();
var userlogin = user.get_loginName();
Related Content
SharePoint JavaScript Client Object Model why not
SharePoint 2013 Script Editor and Embed Code
SharePoint 2013 JavaScript Add List with Columns
JavaScript - Client Object Model - Add New Item
function AddListItem() {
try {
//Get the context, web, and the list
var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
var list = web.get_lists().getByTitle('TheList');
//Add new list item
var itemCreationInfo = new SP.ListItemCreationInformation();
var newitem = list.addItem(itemCreationInfo);
newitem.set_item("Title", "New List Item added with JavaScript and COM");
newitem.update();
ctx.executeQueryAsync(onSucceededCallback, onFailedCallback);
}
catch (e) {
alert(e);
}
}
function onSucceededCallback() {
alert('New list item is added');
}
function onFailedCallback() {
alert('Error: ' + args.get_message());
}
try {
//Get the context, web, and the list
var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
var list = web.get_lists().getByTitle('TheList');
//Add new list item
var itemCreationInfo = new SP.ListItemCreationInformation();
var newitem = list.addItem(itemCreationInfo);
newitem.set_item("Title", "New List Item added with JavaScript and COM");
newitem.update();
ctx.executeQueryAsync(onSucceededCallback, onFailedCallback);
}
catch (e) {
alert(e);
}
}
function onSucceededCallback() {
alert('New list item is added');
}
function onFailedCallback() {
alert('Error: ' + args.get_message());
}
JavaScript and Client Object Model - Get Latest Video Pages
//initiates function SetLabelValues on page load:
ExecuteOrDelayUntilScriptLoaded(GetValues, "sp.js");
function GetValues()
{
//Get context - video site
var ctx = new SP.ClientContext("/videositename/");
//Get web:
var web = ctx.get_web();
//Get list
var videoList = web.get_lists().getByTitle('Pages');
//Get the latest video
var caml = new SP.CamlQuery();
this.allVideos = videoList.getItems(caml);
//Video is a custom site column
ctx.load(this.allVideos, "Include(Title,Video,Created, Comments,FileRef)");
//Video List
var enumerator = this.allVideos.getEnumerator();
while (enumerator.moveNext()) {
var li = enumerator.get_current();
var videourl = li.get_item("FileRef");
var videotitle=li.get_item("Title");
//build the str string here...
}
//Write list to a div tag with id="VideoList"
var div = document.getElementById("VideoList");
div.innerHTML = str;
}
lørdag den 14. januar 2012
dk.msn.com News style with Content Query
Coding News web part that resembles News display at dk.msn.com (or uk.msn.com) with one top headline and 5 thumbnail pictures below was not that hard to code.
Here are the things that you have to code:
- display the latest item as headline with large picture
- display as thumbnails, both the latest item and the last 5-6 items below the headline news
- shuffle the items - display item no. 2 as headline and after some time, display item no. 3 and so on
- fade the thumbnail that is currently displayed as headline
- allow user to click or move the mouse over thumbnails and choose which news is displayed as headline
- allow user to click on the item and display the entire item on another page
Here are some tips:
1. Create a custom style in your custom ItemStyle.xsl that is referenced from Content Query web part
2. Create a variable RowNum to display the latest news item as top headline:
..xsl:if test="$RowNum < 1">...
4. Define both a and img tag with id, so you can reference them from JavaScript:
id="newsdisplayimage" src="{$SafeImageUrl}" title="{@ImageUrlAltText}" />
5. Define onClick and onMouseOver for thumbnail image link:
6. Define thumbnail image with id:
7. Create a reference to JavaScript on the page
8. ShowLarge JavaScript function - example of how to display the thumbnail image as headline - large image:
function ShowLarge(Row) { try {var image=document.getElementById(Row + "_image");var mainimage = document.getElementById("newsdisplayimage");
mainimage.filters.item("DXImageTransform.Microsoft.Fade").apply();
mainimage.src=image.src;
mainimage.filters.item("DXImageTransform.Microsoft.Fade").play();
9. Shuffle between news items:
var t=setInterval("ShowLarge()",12000);
10. Fade thumbnail image for the current headline:
image.style.filter="Alpha(opacity=50)";
mandag den 17. oktober 2011
SharePoint 2010 and How to Build XML and Display ListItem with XSLT
In the following, I'll explain how to build XML on-the-fly and display data with XSLT. The advantage of this approach is that you always can edit the way data is displayed without changing the code in C# and deploying the new assembly.
So, if you are tired of using StringBuilder to display data in your web parts, check out the description below:
I assume that you know how to create a web part in VisualStudio and write the code to fetch SPListItem that I defined as "projectitem" in the code.
SPListItem projectitem=.....
You can define the path to XSLT file as a web part property that is editable in the web part ToolPane:
private string _xslt = "/Style Library/Projects/ProjectInfo.xsl";
[WebBrowsable(true),
Category("ProjectInfo settings"),
DefaultValue("Current"),
Personalizable(PersonalizationScope.Shared),
WebDisplayName("XSLT path"),
WebDescription("Pat to XSL file")]
public string XSLT
{
get { return _xslt; }
set { _xslt = value; }
}
Also, define the string that will contain the XML, built on the fly:
string xmlInfo = "";
The code is used to fetch the item from a "Project list" that contains metadata about projects. Whilst I also defined the list of ProjectFields as:
This list is used in the code to save all the list item values - the values, defined in the list item columns.
The code loops through the list item fields (columns), so I also defined the field name and field value as FieldName and FieldValue:
class ProjectFields { public string FieldName { get; set; } public string FieldValue { get; set; } }
I loop through the list item fields (columns):
foreach (SPField field in projectitem.Fields){}
Than, I fetch the value for each field (column). The code to fetch the field value is different for each field type, so
I write something like this:
if (field.Type == SPFieldType.Text){}
or
if (field.TypeAsString == "TaxonomyFieldType"){}
or
if (field.Type == SPFieldType.User){}
Don't forget to check for fields and empty field values:
if (projectitem[field.Title]!=null){}
and
if (projectitem[field.Title].ToString() != ""){}
At the end of the loop, the field name and field value are saved in the list:
projectList.Add(new ProjectFields { FieldName = field.Title.Replace(" ", "_"), FieldValue = itemvalue });
Than, the foreach loop is closed and I can build the XML on the fly:
XElement xml = new XElement("Project");
foreach (ProjectFields data in projectList)
{
xml.Add(new XAttribute(data.FieldName, data.FieldValue));
}
Than, save the XML to a string:
xmlInfo = xml.ToString();
Finally, render the XML with XSL:
protected override void RenderContents(HtmlTextWriter output)
{
RenderChildren(output);
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
if (xmlInfo.ToString() != "")
{
string rootWebUrl = SPContext.Current.Site.RootWeb.Url.ToString();
XslCompiledTransform xslt = new XslCompiledTransform();
XmlDocument loadXsl = new XmlDocument();
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
XsltSettings xslt_settings = new XsltSettings();
xslt_settings.EnableScript = true;
xslt.Load(rootWebUrl + XSLT, xslt_settings, resolver);
XmlReader xreader = XmlReader.Create(new System.IO.StringReader(xmlInfo.ToString()));
System.Xml.XPath.XPathDocument pData = new System.Xml.XPath.XPathDocument(xreader);
xslt.Transform(pData, null, output);
}
});
} .......end with catch....
In VisualStudio, add a new module to your project - I called it XSLT and changed the Elements.xml file so it looks like this:
Than, add a new XSL file and call it ProjectInfo.xsl. Here is an example of how to display a field value called
ProjectManager in .xsl file:
NOTICE: DELETE ALL THE br TAGS FROM THE CODE
torsdag den 31. marts 2011
SP.CamlQuery & HTML web part
How to display list content using HTML web part?
1. Add HTML Form Web Part to the page in SharePoint 2010
2. Click on the arrow and choose Edit Web Part
3. In the Tool Pane, click on Source Editor button
4. Add the following code (delete all br />):
1. Add HTML Form Web Part to the page in SharePoint 2010
2. Click on the arrow and choose Edit Web Part
3. In the Tool Pane, click on Source Editor button
4. Add the following code (delete all br />):
tirsdag den 14. december 2010
70-573: Top 5 answers
1. Client object model: .ExecuteQuery() is missing somewhere after Load method
2. Memory leaks, bad performance: site.Dispose() is missing
3. Permissions, sandboxed solution: RunWithElevatedPrivileges is either missing or not supported
4. Not the right answer: Changes in Web.config, overwrite standard SharePoint files, and modify registry
5. Always the right answer: change Onet.xml
2. Memory leaks, bad performance: site.Dispose() is missing
3. Permissions, sandboxed solution: RunWithElevatedPrivileges is either missing or not supported
4. Not the right answer: Changes in Web.config, overwrite standard SharePoint files, and modify registry
5. Always the right answer: change Onet.xml
søndag den 12. december 2010
Upgrade to SharePoint 2010 – top 5 hurdles
1. System requirements: Minimum 4GB RAM, 64-bit Windows Server 2008 with SP2, 64-bit SQL Server 2005 with SP2 or later or SQL Server 2008.
2. Customizations: Just about everything, from master pages to MySites or RadEditor is customized, and you are afraid that it can’t be easily upgraded.
3. Social features, the ribbon etc.: Change even for the better requires additional resources and time to learn about the new platform.
4. People and technology issues: Who’s to blame if it doesn’t work; you, your vendor, or Microsoft? Is there an idea to wait for the official service pack 1?
5. Business value: Do benefits outweigh the cost of upgrade?
2. Customizations: Just about everything, from master pages to MySites or RadEditor is customized, and you are afraid that it can’t be easily upgraded.
3. Social features, the ribbon etc.: Change even for the better requires additional resources and time to learn about the new platform.
4. People and technology issues: Who’s to blame if it doesn’t work; you, your vendor, or Microsoft? Is there an idea to wait for the official service pack 1?
5. Business value: Do benefits outweigh the cost of upgrade?
lørdag den 11. december 2010
Top 5 things I like about SharePoint
Besides being a corporate news channel and storage for documents, can you name 5 things SharePoint is used for in your organization?
Let me help you with top 5 things I like about SharePoint:
1. Document management: documents and pages based on document/page templates and content types, and metadata driven navigation and search
2. User Profiles: clearly defined and easy to find user skills, responsibilities, and activities
3. Lists: more effective and flexible work with information held and displayed as calendars, surveys, car rental, tasks, Q&A etc.
4. Role based content: metadata (skills, department etc.) in your user profile defines the content that you see; news, documents, pages, and lists
5. Web 2.0: Even the corporate news can be a two way communication with comments and rating that allows you to contribute with your knowledge and opinion
Let me help you with top 5 things I like about SharePoint:
1. Document management: documents and pages based on document/page templates and content types, and metadata driven navigation and search
2. User Profiles: clearly defined and easy to find user skills, responsibilities, and activities
3. Lists: more effective and flexible work with information held and displayed as calendars, surveys, car rental, tasks, Q&A etc.
4. Role based content: metadata (skills, department etc.) in your user profile defines the content that you see; news, documents, pages, and lists
5. Web 2.0: Even the corporate news can be a two way communication with comments and rating that allows you to contribute with your knowledge and opinion
tirsdag den 4. maj 2010
SharePoint 2010 custom stylesheet for standard list views
Custom List View XSL or how to change Add new item link to Add new umbrella link
Each time you create a list in SharePoint, you also create a List View web part that displays the content of the list. List View web parts works in the same way as all other web parts. You are able to pick a list view or change web part title. They are phenomenal, as long as you stay at the same site (web) as your list.
I noticed a new tab in the Tool Pane that opens when you select Edit Web Part. Aside from Appearance and Layout tabs, there is new Miscellaneous tab, and I was wondering for some time about a XSL Link property text box. It looks much like the ItemXslLink property for Content Query web part. I used ItemXslLink property to write a reference to another XSL file and override the standard link to ItemStyle.xsl file, stored in Style Library. I used to copy the content of the standard ItemStyle.xsl and create my own styles. My problem with List View and XSL Link was that List View web part doesn't link to XSL file that is stored somewhere on the portal. Well, everybody can create XSL file and upload it, but what is the chance that it will work. Zero, I think.
I got it to work though. There are easy three steps:
1. Get the standard XSL stylesheet
2. Upload the XSL stylesheet in Site Assets library and modify it
3. Configure the List View for your custom stylesheet
1. Get the standard XSL stylesheet:
- create a list in SharePoint 2010
- open the list in browser
- click on List tab in the ribbon and choose Modify View->Modify in SharePoint Designer.
- click on XsltListView web part in Design view
- click on Design tab in the ribbon
- click on Customize XSLT->Customize Entire View
- copy all the code starting and ending with xsl stylesheet tag
- open Notepad and paste the code
- save the file as ListView.xsl file
2. Upload the XSL stylesheet in Site Assets library and modify it
- open SharePoint 2010 portal in SPD
- click on Site Assets
- click on Import Files in the ribbon and upload ListView.xsl
- check out the ListView.xsl and open it
- locate 'Add new item' and change it to 'Add new umbrella'
- save and check in the file
3. Configure the List View for custom stylesheet
- add the ListView web part for yor list to the page
- click on the web part title and select Edit Web Part
- expand Miscellaneous tab
- write: /SiteAssets/ListView.xsl in XSL Link text box
- click on OK button to save the web part settings
Other Things I Wrote
Customize Content Query
Image Renditions in SharePoint 2013
The Story About SharePoint 2013
SharePoint 2013 JavaScript - Office Store App Licensing Script
Use ListView in SharePoint 2013 Apps
Each time you create a list in SharePoint, you also create a List View web part that displays the content of the list. List View web parts works in the same way as all other web parts. You are able to pick a list view or change web part title. They are phenomenal, as long as you stay at the same site (web) as your list.
I noticed a new tab in the Tool Pane that opens when you select Edit Web Part. Aside from Appearance and Layout tabs, there is new Miscellaneous tab, and I was wondering for some time about a XSL Link property text box. It looks much like the ItemXslLink property for Content Query web part. I used ItemXslLink property to write a reference to another XSL file and override the standard link to ItemStyle.xsl file, stored in Style Library. I used to copy the content of the standard ItemStyle.xsl and create my own styles. My problem with List View and XSL Link was that List View web part doesn't link to XSL file that is stored somewhere on the portal. Well, everybody can create XSL file and upload it, but what is the chance that it will work. Zero, I think.
I got it to work though. There are easy three steps:
1. Get the standard XSL stylesheet
2. Upload the XSL stylesheet in Site Assets library and modify it
3. Configure the List View for your custom stylesheet
1. Get the standard XSL stylesheet:
- create a list in SharePoint 2010
- open the list in browser
- click on List tab in the ribbon and choose Modify View->Modify in SharePoint Designer.
- click on XsltListView web part in Design view
- click on Design tab in the ribbon
- click on Customize XSLT->Customize Entire View
- copy all the code starting and ending with xsl stylesheet tag
- open Notepad and paste the code
- save the file as ListView.xsl file
2. Upload the XSL stylesheet in Site Assets library and modify it
- open SharePoint 2010 portal in SPD
- click on Site Assets
- click on Import Files in the ribbon and upload ListView.xsl
- check out the ListView.xsl and open it
- locate 'Add new item' and change it to 'Add new umbrella'
- save and check in the file
3. Configure the List View for custom stylesheet
- add the ListView web part for yor list to the page
- click on the web part title and select Edit Web Part
- expand Miscellaneous tab
- write: /SiteAssets/ListView.xsl in XSL Link text box
- click on OK button to save the web part settings
Customize Content Query
Image Renditions in SharePoint 2013
The Story About SharePoint 2013
SharePoint 2013 JavaScript - Office Store App Licensing Script
Use ListView in SharePoint 2013 Apps
mandag den 8. februar 2010
Customize Content Query in SharePoint 2010
In SharePoint 2010, there is no need to define CommonViewFields in Content Query web part in order to display custom fields. As in SharePoint 2007, the Content Query web part in SharePoint 2010 is set to display items via XSL file ItemStyle.xsl.The new and very cool feature that comes with SharePoint 2010 is that Content Query web part detects the fields such as Title, Dsecription etc. that are defined in the XSL file and displays those fields in Tool Pane. Each field is displayed as a text box for you to enter the field name.
It's much easier to understand if you try it your self. Let's say that you have Customer content type that has a Title,Comments, and Products fields (columns).
Here is the example of how to display Title, Comments field as description, and a Products custom field.
0. Create Customer content type and a list with this content type
1. Add a Content Query web part to the page
2. Select the list and a Products content type
3. Change the name to Products in Appearance and click on OK button in the bottom
4. Click on the arrow in upper right corner of the web part's title and choose Export
5. Save the web part as Products.webpart to your desktop
6. Open the root of your site collection, click on View All Site Contents and open the Style Library
7. Open XSL Style Sheets folder
8. Select ItemStyle.xsl and click on Download a Copy in the ribbon
9. Save the ItemStyle.xsl file to your desktop
10. Open the Products.webpart file in Notepad
11. Locate the ItemXslLink property
12. Change it to
13. Save the changes
14. Open your site in browser or SharePoint Designer and open Site Assets library
15. Upload the ItemStyle.xsl file into this Library
16. Open the site in browser, edit the page
17. Click on Add a Web Part in web part zone and click on Upload a web part
18. Browse to Products.webpart and upload it
19. Click on Add a Web Part again and add the Products.webpart
20. Open the Tool Pane for Products web part and fold out the Presentation group.
21. Here you can see Link, Image, Title, and Description text boxes in Fields to display
22. Click on OK button and save the web part settings
23. Use SharePoint Designer to open the ItemStyle.xsl (in Site Assets library) and locate
24. Scroll down and you'll find
25. Open the Tool Pane for Products web part and write Comments in Description text box, and save the web part settings (click on OK button)
26. Open Site Assets library in SharePoint Designer and check out the ItemStyle.xsl file
27. Add @Products to the XSL like this:
28. Save and check in the ItemStyle.xsl
29. Refresh the page in browser and edit the Products web part
30. When you open Presentation group in Tool Pane, you'll see a new text box called Products
31. Write Products in the text box and click on OK button to save the web part settings
Other Things I Wrote (SharePoint 2013)
Script Editor and Embed Code
JavaScript - Add List with Columns
Adventures with Napa Apps in SharePoint 2013
Install SharePoint 2013 Public Beta with no Domain Controller
Metadata Driven Navigation
Geolocation
It's much easier to understand if you try it your self. Let's say that you have Customer content type that has a Title,Comments, and Products fields (columns).
Here is the example of how to display Title, Comments field as description, and a Products custom field.
0. Create Customer content type and a list with this content type
1. Add a Content Query web part to the page
2. Select the list and a Products content type
3. Change the name to Products in Appearance and click on OK button in the bottom
4. Click on the arrow in upper right corner of the web part's title and choose Export
5. Save the web part as Products.webpart to your desktop
6. Open the root of your site collection, click on View All Site Contents and open the Style Library
7. Open XSL Style Sheets folder
8. Select ItemStyle.xsl and click on Download a Copy in the ribbon
9. Save the ItemStyle.xsl file to your desktop
10. Open the Products.webpart file in Notepad
11. Locate the ItemXslLink property
12. Change it to
13. Save the changes
14. Open your site in browser or SharePoint Designer and open Site Assets library
15. Upload the ItemStyle.xsl file into this Library
16. Open the site in browser, edit the page
17. Click on Add a Web Part in web part zone and click on Upload a web part
18. Browse to Products.webpart and upload it
19. Click on Add a Web Part again and add the Products.webpart
20. Open the Tool Pane for Products web part and fold out the Presentation group.
21. Here you can see Link, Image, Title, and Description text boxes in Fields to display
22. Click on OK button and save the web part settings
23. Use SharePoint Designer to open the ItemStyle.xsl (in Site Assets library) and locate
24. Scroll down and you'll find
25. Open the Tool Pane for Products web part and write Comments in Description text box, and save the web part settings (click on OK button)
26. Open Site Assets library in SharePoint Designer and check out the ItemStyle.xsl file
27. Add @Products to the XSL like this:
28. Save and check in the ItemStyle.xsl
29. Refresh the page in browser and edit the Products web part
30. When you open Presentation group in Tool Pane, you'll see a new text box called Products
31. Write Products in the text box and click on OK button to save the web part settings
Other Things I Wrote (SharePoint 2013)
Script Editor and Embed Code
JavaScript - Add List with Columns
Adventures with Napa Apps in SharePoint 2013
Install SharePoint 2013 Public Beta with no Domain Controller
Metadata Driven Navigation
Geolocation
tirsdag den 22. december 2009
Turn on the Developer Dashboard with stsadm
In my opinion, this stsadm command is slitely more elegant than the example of console application that uses SPWebService and SPDeveloperDashboardSettings.
It activates a Developer dashboard icon in the upper right corner of any page:
stsadm -o setproperty -pn developer-dashboard -pv OnDemand
It activates a Developer dashboard icon in the upper right corner of any page:
stsadm -o setproperty -pn developer-dashboard -pv OnDemand
søndag den 20. december 2009
SharePoint 2010: custom content type & page layout
Creating SharePoint 2010 features and web parts in Visual Studio 2010 is extremely fast and a lot of fun. There is a template for creating new content type, and it is very easy to use. There is no template for creating master pages and page layouts. As most of the projects, I'm involved in, require development of one or more master pages and page layouts, I thought that it would be a good idea to figure that out.
I created an empty project in Visual Studio in order to create new NewsPage content type, some custom columns and page layout. Although I would normally create a feature containing both the content type and page layout, I decided to create two features; Feature1 and Feature2, no. 1 for the content type, and no. 2 for the page layout:
1. Open VisualStudio 2010
2. Click on File->New project
3. Choose "Empty SharePoint Project" from the template list and click "OK"
4. Choose your local SP2010 site as the site to debug
5. Choose sandboxed deployment
6. In solution Explorer rightclick on "Features" node and choose "Add feature"
7. When "Feature1" is created, rightclick on "Features" again and choose "Add feature"
Then I created a "NewsPage" content type:
1. Rightclick on your project and choose "Add"->"New item"
2. Choose "Content Type" from the list and click on "Add"
3. Choose "Article page" from the drop down menu and click on "Finish"
4. Open Elements.xml and change the "Name" to NewsPage
5. Change "Group" and "Description" too
Add custom fields to NewsPage content type - Elements.xml should look like this (without br tag):
Deploy the NewsPage content type to the site:
1. Open the Feature1.feature node (under Feature1) and fill out the name and Description for the feature. Check if the newly created content type is placed in "Items in the Feature" window.
2. Rightclick on the project and choose "Deploy"
3. Open the site, and check if the feature is on the list of features on Site collection features page in Site Settings
4. You should also be able to see NewsPage content type on Site Settings->Site content types page
That was an easy one. Let's create a page layout that has NewsPage content type:
1. Rightclick on the project and choose "Add"->"New item"
2. Choose "Empty Element" from the list
3. Rightclick on the project and choose "Add"->"New item" again
4. Choose "Module"
5. Rename "Sample.txt" to "NewsPage.aspx"
6. Open NewsPage.aspx and paste this code:
(without br tag):
Only Title and News Category fields are added, and you can add other fields later.
It's imortant to define NewsPage.aspx as NewsPage content type and deploy it as Feature2 to the site:
1. Open Elements.xml (under Module1)
2. Paste this code:
(without br tag):
3. Open Feature2.feature and fill the title and description of the feature
4. Check also if EmptyElement1 is part of the Feature2
5. Rightclick on the project an choose "Deploy"
6. Check the Output window in VisualStudio if the deployment is finished
7. Open the site in browser and open Site Settings
8. Open "Master pages and page layouts" to check if NewsPage.aspx is on the list as the NewsPage content type
Other Things I Wrote
Style with Content Query
Customize Content Query
SharePoint 2013 JavaScript - Add List with Columns
I created an empty project in Visual Studio in order to create new NewsPage content type, some custom columns and page layout. Although I would normally create a feature containing both the content type and page layout, I decided to create two features; Feature1 and Feature2, no. 1 for the content type, and no. 2 for the page layout:
1. Open VisualStudio 2010
2. Click on File->New project
3. Choose "Empty SharePoint Project" from the template list and click "OK"
4. Choose your local SP2010 site as the site to debug
5. Choose sandboxed deployment
6. In solution Explorer rightclick on "Features" node and choose "Add feature"
7. When "Feature1" is created, rightclick on "Features" again and choose "Add feature"
Then I created a "NewsPage" content type:
1. Rightclick on your project and choose "Add"->"New item"
2. Choose "Content Type" from the list and click on "Add"
3. Choose "Article page" from the drop down menu and click on "Finish"
4. Open Elements.xml and change the "Name" to NewsPage
5. Change "Group" and "Description" too
Add custom fields to NewsPage content type - Elements.xml should look like this (without br tag):
Deploy the NewsPage content type to the site:
1. Open the Feature1.feature node (under Feature1) and fill out the name and Description for the feature. Check if the newly created content type is placed in "Items in the Feature" window.
2. Rightclick on the project and choose "Deploy"
3. Open the site, and check if the feature is on the list of features on Site collection features page in Site Settings
4. You should also be able to see NewsPage content type on Site Settings->Site content types page
That was an easy one. Let's create a page layout that has NewsPage content type:
1. Rightclick on the project and choose "Add"->"New item"
2. Choose "Empty Element" from the list
3. Rightclick on the project and choose "Add"->"New item" again
4. Choose "Module"
5. Rename "Sample.txt" to "NewsPage.aspx"
6. Open NewsPage.aspx and paste this code:
(without br tag):
Only Title and News Category fields are added, and you can add other fields later.
It's imortant to define NewsPage.aspx as NewsPage content type and deploy it as Feature2 to the site:
1. Open Elements.xml (under Module1)
2. Paste this code:
(without br tag):
3. Open Feature2.feature and fill the title and description of the feature
4. Check also if EmptyElement1 is part of the Feature2
5. Rightclick on the project an choose "Deploy"
6. Check the Output window in VisualStudio if the deployment is finished
7. Open the site in browser and open Site Settings
8. Open "Master pages and page layouts" to check if NewsPage.aspx is on the list as the NewsPage content type
Other Things I Wrote
Style with Content Query
Customize Content Query
SharePoint 2013 JavaScript - Add List with Columns
lørdag den 5. september 2009
SharePoint 2010
I've got Office 2010, SharePoint Designer 2010, SharePoint Workspace 2010, and InfoPath 2010 (Technical Preview). I've also seen a couple of web casts about SharePoint 2010 at PET meeting at Microsoft. I can't wait to get my hands on beta 2 version.
I'm all set up for the SharePoint 2009 Conference in October, and I hope that by that time I can start writing about the new version.
I'm all set up for the SharePoint 2009 Conference in October, and I hope that by that time I can start writing about the new version.
Abonner på:
Opslag (Atom)

