SchedulePicker Class (Microsoft.SharePoint.WebControls)
SchedulePicker Class (Microsoft.SharePoint.WebControls)

Namespace: Microsoft.SharePoint.WebControls
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Syntax

'Usage

Dim instance As SchedulePicker


'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
Inheritance Hierarchy

System.Object
   System.Web.UI.Control
     System.Web.UI.TemplateControl
       System.Web.UI.UserControl
        Microsoft.SharePoint.WebControls.SchedulePicker
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also

Community Content

Using the SchedulePicker
Added by:Robin Meuré

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();
            }
            
        }       
        
    }
}
© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View