Thursday, March 31, 2011

SharePoint custom Master Page Do Not Print

Issue:
When using Microsoft custom Master Pages, print preview pages dont show any content in the body of the page.
Reason:

Sharepoint use core.css file in which they write few classes where they says that this class should not be use for print/media.

Solution:-

While customizing make sure not to use those classes on top of your body area. So that it won’t hide it.

Few classes: Few of classes I am mentioning below which if you use on top of body area then print will not display content.

.ms-leftareacell, .ms-globallinks, .ms-siteaction, .ms-areaseparatorleft, .ms-rightareacell, .ms-areaseparatorright, .ms-areaseparatorcorner, .ms-titlearealeft, .ms-titlearearight, .ms-searchform, .ms-banner, .ms-buttonheightwidth, .ms-buttonheightwidth2
Hope this helps you.

Thanks!
Avinash

Using Microsoft Custom MasterPages I don't see content in Print Preview

When using Microsoft custom Master Pages, print preview pages dont show any
content in the body of the page. 
 
Reason: Sharepoint use core.css file in which they write few classes where they says that this class should not be use for print/media.
 
Solution: While customizing make sure not to use those classes on top of your body area. So that it wont hide it.
Few classes: Few of classes I m mentioning below which if you use on top of body area then print will not display content.
                                  .ms-leftareacell,.ms-globallinks,.ms-siteaction,.ms-areaseparatorleft,.ms-rightareacell,.ms-areaseparatorright,                                  .ms-areaseparatorcorner,.ms-titlearealeft,.ms-titlearearight,.ms-searchform,.ms-banner,.ms-buttonheightwidth,.ms-buttonheightwidth2

Hope this help you.

Thanks!
Avinash

print preview dont show any content of the sharepoint page

 
When using Microsoft custom Master Pages, print preview pages dont show any
content in the body of the page. 
 
Reason: Sharepoint use core.css file in which they write few classes where they says that this class should not be use for print/media.
 
Solution: While customizing make sure not to use those classes on top of your body area. So that it wont hide it.
Few classes: Few of classes I m mentioning below which if you use on top of body area then print will not display content.
                                  .ms-leftareacell,.ms-globallinks,.ms-siteaction,.ms-areaseparatorleft,.ms-rightareacell,.ms-areaseparatorright,                                  .ms-areaseparatorcorner,.ms-titlearealeft,.ms-titlearearight,.ms-searchform,.ms-banner,.ms-buttonheightwidth,.ms-buttonheightwidth2

Hope this help you.

Thanks!
Avinash

Monday, February 7, 2011

Retrieve Web part Title in Contentquerymain.xsl

To retrieve webpart title in Contentquerymain.xsl, You can use Feed Title web part property, that if not set is equal to web part Title; to achieve this you need to add
<xsl:param name="FeedTitle" />
to your custom ContentQueryMain.xsl in the params section.
Doing this the param FeedTitle will contain the web part Title and can be used inside xsl as below code
<xsl:value-of select="$FeedTitle"/>

Thanks!
Avinash

Wednesday, January 26, 2011

Programmatically adding items to a SharePoint list

using(SPSite site = new SPSite("http://"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["SharePointList"];
SPListItem Item = list.Items.Add();
item["Title"] = txtCompanyName.Text;
//can add required items

item.Update();
}
}

Note: 1. No need to use SPSecurity.RunWithElevatedPrivileges.
          2. No need to use allowunsafeupdate property
          3. No need to update web object.

Creating a List programmatically using the sharepoint object model

Creating a List programmatically with out of the box List Template Types


You can create a list by picking one of the List Template Types available in the SPListTemplateType object. A full list can be found here.


Guid listId = web.Lists.Add("Test Custom List", "Name of list", SPListTemplateType.GenericList);
SPList list = web.Lists[listId];

OOTB List Templates

NameBaseType
EventsGenericList
ContactsGenericList
TasksGenericList
PictureLibraryDocumentLibrary
DiscussionBoardGenericList
SurveySurvey
DocumentLibraryDocumentLibrary
LinksGenericList
Document LibraryDocumentLibrary
AnnouncementsGenericList
GenericListGenericList
WorkflowHistoryGenericList
DataConnectionLibraryDocumentLibrary
DataSourcesDocumentLibrary
GanttTasksGenericList
CustomGridGenericList
NoCodeWorkflowsDocumentLibrary
XMLFormDocumentLibrary
WebPageLibraryDocumentLibrary
WorkflowProcessGenericList
Form LibraryDocumentLibrary
wikiDocumentLibrary
Wiki Page LibraryDocumentLibrary
Picture LibraryDocumentLibrary
PictureDocumentLibrary
ContactsGenericList
CalendarGenericList
Discussion BoardGenericList
Project TasksGenericList
Issue TrackingIssue
Custom ListGenericList
Custom List in Datasheet ViewGenericList
SurveySurvey
Custom Workflow ProcessGenericList
Languages and TranslatorsGenericList
Translation Management LibraryDocumentLibrary
DataSourcesDocumentLibrary
Data Connection LibraryDocumentLibrary
Workflow HistoryGenericList
No Code WorkflowsDocumentLibrary