I'll write more later, now just code:
<%@ Page Language="C#" AutoEventWireup="false" CodeBehind="PrintReport.aspx.cs"
Inherits="ApplicationPages.PrintReport" DynamicMasterPageFile="~masterurl/default.master" %>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<%-- MY STUFF HERE--%>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
<style type="text/css">
.s4-notdlg
{
display: none !important;
visibility: hidden !important;
}
#s4-ribboncont
{
display: none !important;
visibility: hidden !important;
}
#s4-ribbonrow
{
display: none !important;
visibility: hidden !important;
}
#s4-statusbarcontainer
{
display: none !important;
visibility: hidden !important;
}
#s4-titlerow
{
display: none !important;
visibility: hidden !important;
}
/*--Hide Quick Launch --*/
#s4-leftpanel
{
display: none;
}
.s4-ca
{
margin-left: 0px;
}
</style>
</asp:Content>
<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
</asp:Content>
<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea"
runat="server">
</asp:Content>
<asp:Content ID="PlaceHolderPageImage" ContentPlaceHolderID="PlaceHolderPageImage"
runat="server">
</asp:Content>
<asp:Content ID="PlaceHolderLeftNavBar" ContentPlaceHolderID="PlaceHolderLeftNavBar"
runat="server">
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="PlaceHolderTitleLeftBorder" runat="server">
</asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="PlaceHolderTitleAreaClass" runat="server">
</asp:Content>
<asp:Content ID="Content9" ContentPlaceHolderID="PlaceHolderBodyAreaClass" runat="server">
</asp:Content>
<asp:Content ID="Content10" ContentPlaceHolderID="PlaceHolderBodyLeftBorder" runat="server">
</asp:Content>
<asp:Content ID="Content11" ContentPlaceHolderID="PlaceHolderTitleRightMargin" runat="server">
</asp:Content>
<asp:Content ID="Content12" ContentPlaceHolderID="PlaceHolderBodyRightMargin" runat="server">
</asp:Content>
<asp:Content ID="Content13" ContentPlaceHolderID="PlaceHolderTitleAreaSeparator"
runat="server">
</asp:Content>
Hiding quicklaunch method is taken from here http://chrisstahl.wordpress.com/2010/03/15/hide-the-quick-launch-in-sharepoint-2010/
Polish developer blog, I will try to post some tips for Sharepoint and .Net in general.
Tuesday, 28 December 2010
Tuesday, 7 December 2010
Debugging Sharepoint timer jobs - gotchas
Yesterday I was having a problem... I wasn't able to debug my new timer job. I know VS is automatically attached w3wp.exe so I thought I should be able to debug without any problem. The thing I didn’t know was, that in case I want to debug timer job I should manually attach my VS to owstimer.exe using an option “attach to process” in the debug menu.
All right I was happy to go, did one debug, changed some code and deployed it again, reattach to owstimer, start job manually from central administration, breakpoint hit and… wtf, why is the code behaving so strange, it doesn’t stop on breakpoints etc… What I didn’t know, was the fact, that restarting owstimer is necessary. Remember: Always restart your owstimer.exe
Friday, 3 December 2010
Strange behaviour - DateTime in Sharepoint
Hi there,
First post... yuppe :)
Since yesterday I was having a problem copying an item in calendar list. Actually I was trying to create cloned item and set its "EventDate" and "EndDate" one month forward. At first sight it looked like an one day event was suddenly becoming two days event. Then, after few searches it turned out, sharepoint was substracting one hour while doing item.update(). Finally i got it to work, here's a quick solution:
First post... yuppe :)
Since yesterday I was having a problem copying an item in calendar list. Actually I was trying to create cloned item and set its "EventDate" and "EndDate" one month forward. At first sight it looked like an one day event was suddenly becoming two days event. Then, after few searches it turned out, sharepoint was substracting one hour while doing item.update(). Finally i got it to work, here's a quick solution:
SPListItemCollection sourceItems = GetCalendarItems(month1list.SelectedIndex + 1, int.Parse(year1list.SelectedValue)); SPWeb currentWeb = SPContext.Current.Web; SPList list = currentWeb.GetList("Lists/mylist"); foreach (SPListItem oldItem in sourceItems) { SPListItem newItem = CloneItem(oldItem, "mylist"); DateTime eventDate = ((DateTime)newItem["EventDate"]).ToLocalTime(); eventDate = eventDate.AddMonths(monthsToAdd); newItem["EventDate"] = eventDate; DateTime endDate = ((DateTime)newItem["EndDate"]).ToLocalTime(); endDate = endDate.AddMonths(monthsToAdd); newItem["EndDate"] = endDate; newItem.Update(); } public static SPListItem CloneItem(SPListItem sourceItem, string destinationListName) { //copy sourceItem to destinationList SPList destinationList = sourceItem.Web.Lists[destinationListName]; SPListItem targetItem = destinationList.Items.Add(); foreach (SPField f in sourceItem.Fields) { if (!f.ReadOnlyField && f.InternalName != "Attachments" && f.InternalName != "Facilities") { targetItem[f.InternalName] = sourceItem[f.InternalName]; } } //copy attachments foreach (string fileName in sourceItem.Attachments) { SPFile file = sourceItem.ParentList.ParentWeb.GetFile(sourceItem.Attachments.UrlPrefix + fileName); byte[] imageData = file.OpenBinary(); targetItem.Attachments.Add(fileName, imageData); } targetItem.Update(); return targetItem; }Part of the code comes from here http://www.communardo.de/home/techblog/2008/01/08/sharepoint-listenelement-splistitem-in-eine-andere-liste-kopieren/
Subscribe to:
Posts (Atom)