.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

logic for Custom Start Day and End Day for a week.

Posted By:      Posted Date: September 21, 2010    Points: 0   Category :.NET Framework

Hi All,

We have a unique requirment where we have our own start day of a week and end day of a week(C#),

Contrary to the existing Date Time class whose start day is Sunday and end day is Saturday, we have Wednesday as our start day and Monday as our EndDay (and this will vary per client).

and we need to implement the following logic

a) for a given date get the start Date of a week and end Date of a week

Ex: based on the above if the current day is  23/Sep/2010 (Thur) we need to get  22/Sep/2010 (Wed) as our Start Day and 27/Sep/2010 (Mon) as our end day


Can anyone help here?




View Complete Post

More Related Resource Links

Where is StartPage.cproj : Custom Start Page Project Template


I am reading through Wrox Professional Visual Studio 2010.
In Chapter 3, there is an example of how to customize and extend the start page.

So he wants you to copy the files from C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\StartPages\<Culture>
C:\Users\<user name>\Documents\Visual Studio 10\StartPages. He say you may need to create this because it may not exist by default. So I would just copy the files into:
C:\Documents and Settings\Sam\My Documents\Visual Studio 2010\StartPages and work from there right?

Then he says double click StartPage.csproj to opent the WPF project in Visual Studio 2010.
But StartPage.csproj simply does not exist anywhere.

I have installed Visual Studio 2010 sdk and the Custom Start Page Project which shows up in extension manager.
I just can't figure out how to use it.

I am on Windows XP.

Custom workflows don't start via user accounts

Hi! Topic started here, http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010setup/thread/a51673e5-ec13-408d-b512-4cc98d84fdd8 As adviced copy it  to this subforum. I have the following problem. Custom workflows dont start. In the log there are following errors: Workflow Infrastructure 72fv Unexpected AutoStart Workflow: System.ArgumentException: New instances of this workflow template are currently disallowed. at Microsoft.SharePoint.Workflow.SPWorkflowManager.StartWorkflowElev(Object context, SPWorkflowAssociation association, DateTime elevationTimeUtc, SPWorkflowEvent startEvent, SPWorkflowRunOptions runOptions) at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.<>c__DisplayClass1.<AutoStartWorkflow>b__0(SPSite superUserSite, SPWeb superUserWeb) Workflow Infrastructure 72fv Unexpected AutoStart Workflow: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.Workflow.SPWorkflowManager.GetEngine(SPWorkflowAssociation association) at Microsoft.SharePoint.Workflow.SPWorkflowManager.StartWorkflowElev(Object context, SPWorkflowAssociation association, DateTime elevationTimeUtc, SPWorkflowEvent startEvent, SPWorkflowRunOptions runOptions) at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.<>c__DisplayClass1.<AutoStartWorkflow>b__0(SPSite superUserSite, SPWeb

When a Task Expired step in a Start Custom Task Process action is not fired?!

When a Task Expired step is not fired?! I created a simple Workflow using the SharePoint Designer. Added one step to which I added the Start Custom Task Process and set the Due Date "2 minutes after now". For the When a task Expired step of the custom Task I added a Log to History List action, which doesn't seems to be fired. What good be wrong??? All the steps I did to create the workflow: Started SP Designer 2010 and created a reusalbe WF. Added Start Custom Task Process action to step 1. Changed the behavior of the When a task Expired stepof the custom task (added a Log to History List action). Changed the behavior of the Before Task is Assigned by adding a Set Field action which set the Due Date of the task to "Now + 2 minutes". Published the WF and started the WF for a simple list item. Unfortunately the Log to History List actionof the When a task Expired step is never called.

How I select Start of week is Friday from date of Year ?

Hello everyone, I am tring to solve How i select Start date is Friday from week? Details for which i want to show I have dtmDate column in a query. from that date i display week of that date as per using (ww,dtmDate) as dtmWeek, and parameters are StartDate & EndDate Suppose I select StartDate as 1/1/2007 & End Date as 12/31/2007   I  do not want to show Output as: Weeks                      Column1          Column2 1/1/2007 (Thuesday)       5                     6 1/2/2007 (Wed)               4                     2 | | 1/5/2007  (Friday)            1                      8 1/6/2007 (Saturday)        7                     

Start a workflow from timerjob on custom list

I have built a working custom workflow which works fine. I need to start this same workflow from timerjob on a custom list. The timerjob catches following error. Value does not fall within the expected range.Microsoft.SharePoint   at Microsoft.SharePoint.SPFieldMap.GetColumnNumber(String strFieldName)    at Microsoft.SharePoint.SPListItemCollection.GetRawValue(String fieldname, Int32 iIndex)    at Microsoft.SharePoint.SPListItem.GetValue(SPField fld, Int32 columnNumber, Boolean bRaw)    at Microsoft.SharePoint.SPListItem.GetValue(String strName, Boolean bThrowException)    at Microsoft.SharePoint.SPListItem.GetValue(String strName)    at Microsoft.SharePoint.SPListItem.get_EffectiveBasePermissions()    at Microsoft.SharePoint.SPListItem.DoesUserHavePermissions(SPBasePermissions permissionMask)    at Microsoft.SharePoint.Workflow.SPWorkflowManager.StartWorkflow(SPListItem item, SPWorkflowAssociation association, String eventData, Boolean isAutoStart) Any help on this will be appriciated. Thanks,    

How to schedule the custom timer job two times a week to run in MOSS




I have scheduled a custom timer job to run for weekly two times using the spschedule. the string used in the feature event was

"weekly between tue 23:00:00 and thu 23:00:00"

But the problem is i have the job is running only once with the above schedule.How can i run the job twice a week on specific days.


Please share your ideas/solutions to run the custom timer job in  MOSS as per the above schedule.






Thanks keshav,Share point Developer

custom workflow does not start


For some reason i can not start any of custom workflows created in SharePoint Designer 2010.

Those are very simple workflows updating just one field. I have checked in the admin console and user definded workflows are enabled.

Do I need to do anything else to get them working?

Also to be more precise i'm able to start those workflows manually - only automatic starts are issue when item is created or updated.

Custom Workflow won't auto start, but only for one user.


Hi, I have a custom worklfow which is associated with a list.  The workflow is set to auto start when a new item is added to the list.  This happens fine for every user in my organisation, but not for one particular user.  When he submits a new item to the list, nothing happens. The Workflow just will not start.  There are no errors in the log and no attempt is made to start the workflow.  The user is part of a SharePoint group which has contirbute (no delete) permission on the list, just like everyone else in that group who works fine. 

This user also is having problems progressing the workflow, if I start the workflow for him and assign it to him.

The workflow above, manages a CR process, creating tasks for users, taking their responses from custom task forms and populating a CR document held in a document library.  The first step for a user is to fill in a task form which when submitted, sets the task to 100% complete, then populates the CR document with the text the user entered.  Once the task is at 100%, the workflow process is looking for this, closes the task and creates a new task for an approver.  The problem for this same is user is that, the task gets set to 100%, but the CR doesn't progress.  Again, no errors are shown, but the tp_workflowversion value in the userdata table in the content datab

Custom Workflow Activity Works 'Manually' but can't be fired using CodePlex's 'Start Another Wo


Consider 2 lists.  In one list, a workflow runs on an item and if conditions are right, it creates an item in another list, pauses for 5 min, then starts another workflow on that newly created list item (using CodePlex's old 'Start Another Workflow' routine).

All of that works great, used it many times in many situations without fail, so long as I put a pause between the item creation and calling the workflow on the newly created item.

I've started writing my own custom workflow activities, all of them work just fine, up to 5 now, really useful to do little things that SPD Workflow can't do by itself.  The 5th one I added was a very simple 'Now' routine.  The class itself is called 'GetNow' and has a 'RightNow' property that's DateTime and it works great.  I have the need to stamp something with the current date/time, and I haven't modified the underlying record yet, and setting a Date/Time variable only takes Today or a static date/time, with 'Today' returning the current date, but '12 am', which is redunculous, but I digress.

So my step compiles, updated my .ACTIONS file which holds the definition for the other 4 custom routines.  I have the context 'in' parameter and one 'out' parameter for 'RightNow' defined as System.DateTime (which I think is where the problem is, possibly), and it all works if I

create custom timer job to start a workflow


i have created a project with visual studio, to start every day a workflow on every item in a list.

when i place my code in a webpart and i run the code on 1 item, the workflow will start normally.

when i place my code in the  timer job in the execute method, the timer job will finnish normally but there will be not workflow started.


public override void Execute(Guid contentDbId)

            SPWorkflowManager objWorkflowManager = null;
            SPWorkflowAssociationCollection objWorkflowAssociationCollection = null;

            using (SPSite mySiteCollection = new SPSite(siteurl))
                using (SPWeb mySite = mySiteCollection.OpenWeb())

How to add custom redirect logic for VariationRoot.aspx?


Hi All,

We have developed a bilingual publishing portal (English/Arabic). The default logic of VariationRoot.aspx redirects user on clicking Home link to the page according to language setting in browser. The requirement is to redirect user according to the language selection in language selector dropdown. If he is logging in for the first time, the default logic is fine. Please guide me on how we can achieve this.


Rahul Babar


Dot Net, Sharepoint, Infopath Developer

How to start develop custom assemblies in BI

Hello, I have advanced knowledge of SSRS and SSAS and I know VBA language while programming lot of macros. I need to star developing extra features in SSRS in VB .NET, but I dont know where to start, could you let me know about good book or simple reference ? Thanks a lot

Custom Controls in C# .NET

Embedding user controls in a Windows form is just like adding a simple button or text box that are already provided with .NET. These basic controls were written essentially like you code your own controls. Typically the controls you design are to be used in multiple forms or to modularize your code. These reasons help reduce the amount of code you have to type as well as make it easier for you to change your implementation. There should almost never be any reason to duplicate code because it leaves a lot of room for bugs. So, implementing functionality specific to your control in the control's source code is a good idea. This reduces code duplication as well as modularize your code, which is a good programming guideline.

Writing custom MembershipProvider

ASP.NET Membership mechanism allows to use the build-in server tables to store and retrieve user data. By default, this mechanism can only be used with SQL Server database to which Microsoft provides suitable MembershipProvider class.
Inheriting from this abstract class, developer can use his own table(-es) from any database and use any database engine other than SQL Server, like Oracle, DB2 etc.

Logic behind N -Tier Application Development

In the arena of application development, developers all over the world use various programming languages, technical processes, and technical tools. While using number of technical & non technical elements the processes or methods become complex, for simplification of the application development process, developers use various techniques such as dividing the application architecture into layers or parts. In the professional & technical language this separation or division process is called N-Tier Application Development process, where "N" stands for number and "tire" stands for layers or parts.

Custom Editing Behavior for DataGridView TextBox Columns

For various reasons I'm using a DataGridView instead of a ListView, and while configuring the DataGridView to look like a ListView wasn't much of a problem, there's one thing that got on my nerves, which is the behavior of textbox cells in edit mode: It is much too easy to leave the edit mode accidentally, simply by pressing the cursor keys at the wrong time. For example when the text caret is positioned behind the last character of the textbox cell content, and you press the right arrow key

Write Custom WebParts for SharePoint 2007

The popularity of SharePoint Portal Server 2003 led Microsoft to tightly integrate the next SharePoint version, Microsoft Office SharePoint Server (MOSS) 2007, with its ASP.NET 2.0 WebPart framework. This tight integration enables the ASP.NET and SharePoint developer to do a number of things that previously weren't possible
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend