Click to Rate and Give Feedback
Community Content
In this section
Statistics Annotations (0)
Collapse All/Expand All Collapse All
This page is specific to
The 2007 product release

Other versions are also available for the following:
SchedulePicker Class (Microsoft.SharePoint.WebControls)

Namespace: Microsoft.SharePoint.WebControls
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Visual Basic (Declaration)
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level:=AspNetHostingPermissionLevel.Minimal)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel:=True)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level:=AspNetHostingPermissionLevel.Minimal)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel:=True)> _
Public MustInherit Class SchedulePicker
    Inherits UserControl
    Implements IValidator
Visual Basic (Usage)
Dim instance As SchedulePicker
C#
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] 
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel=true)] 
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] 
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)] 
public abstract class SchedulePicker : UserControl, IValidator
System.Object
   System.Web.UI.Control
     System.Web.UI.TemplateControl
       System.Web.UI.UserControl
        Microsoft.SharePoint.WebControls.SchedulePicker
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Using the SchedulePicker      Robin Meuré   |   Edit   |   Show History

This class is very handy when it comes to creating a SPSchedule. The question if of course, when do you need to have a SPSchedule? Well it could be very handy for instance when creating application pages that handle the scheduling of custom timer jobs. So instead of creating your own dropdown’s with all the days of the week and all the possible times and converting to those the proper schedule types that SharePoint has (SPMinuteSchedule, SPHourlySchedule, etc) you can use a control that does everything for you. The only thing you need to specify what the options are that an user can select from by setting the properties.

So using this line in my application page:

  <%@ Register TagPrefix="wssuc" TagName="SchedulePicker" src="~/_controltemplates/SchedulePicker.ascx" %>
  
    
<
wssuc:SchedulePicker id ="SchedulerAction" Weekly ="True" Monthly ="True" Enabled ="True" EnableStateView ="True" runat ="server" />

Generates this result:

Pretty cool eh? So if you only want to have the options to schedule during the week you remove the “Monthly=’True’” property and that part of the control will not be visible.

The only code you have to write to schedule your timer job based on what you configure in this control is this:

  //reference the control like this
  protected SchedulePicker Scheduler

privatevoid InstallTimerJob()
{
CustomTimerJob customTimerJob = new CustomTimerJob("MyCustomJob", webApplication);               
customTimerJob.Schedule = Scheduler.Schedule;                
customTimerJob.Update();
}

And the code to set the control with the configured values is like this:

  protected
  override
  void OnLoadComplete(EventArgs e)
{
    SPWebApplication webApplication = webApplicationSelector.CurrentItem;
    if (!Page.IsPostBack)
    {            
        foreach (SPJobDefinition job in webApplication.JobDefinitions)
        {
            if (job.Name == "MyCustomJob" )
            {                       
                Scheduler.ScheduleString = job.Schedule.ToString();
            }
            
        }       
        
    }
}
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker