Calendar.HasWeekSelectors(CalendarSelectionMode) 方法   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
确定 CalendarSelectionMode 对象是否包含周选择器。
protected:
 bool HasWeekSelectors(System::Web::UI::WebControls::CalendarSelectionMode selectionMode);protected bool HasWeekSelectors (System.Web.UI.WebControls.CalendarSelectionMode selectionMode);member this.HasWeekSelectors : System.Web.UI.WebControls.CalendarSelectionMode -> boolProtected Function HasWeekSelectors (selectionMode As CalendarSelectionMode) As Boolean参数
- selectionMode
- CalendarSelectionMode
返回
如果 CalendarSelectionMode 包含周选择器,则为 true;否则为 false。
示例
下面的代码示例演示如何确定自定义Calendar控件中属性的值HasWeekSelectors。
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page language="c#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>Custom Calendar - HasWeekSelectors - C# Example</title>
  </head>
  <body>
    <form id="Form1" method="post" runat="server">
      <h3>Custom Calendar - HasWeekSelectors - C# Example</h3>
      <aspSample:CustomCalendarHasWeekSelectors
        id="Calendar1"
        runat="server" />
    </form>
  </body>
</html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>Custom Calendar - HasWeekSelectors - VB.NET Example</title>
  </head>
  <body>
    <form id="Form1" method="post" runat="server">
      <h3>Custom Calendar - HasWeekSelectors - VB.NET Example</h3>
      <aspSample:CustomCalendarHasWeekSelectors id="Calendar1" runat="server" />
    </form>
  </body>
</html>
using System.Web;
using System.Security.Permissions;
namespace Samples.AspNet.CS.Controls
{
    [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
    public sealed class CustomCalendarHasWeekSelectors : System.Web.UI.WebControls.Calendar
    {
    protected override void OnPreRender(System.EventArgs e)
    {
      // Determine if a CalendarSelectionMode.DayWeek contains WeekSelectors.
      bool hasWeekSelectors = this.HasWeekSelectors(System.Web.UI.WebControls.CalendarSelectionMode.DayWeek);
      // Call the base's OnPreRender method.
      base.OnPreRender(e);
    }
  }
}
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomCalendarHasWeekSelectors
    Inherits System.Web.UI.WebControls.Calendar
    Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
        ' Determine if a CalendarSelectionMode.DayWeek contains WeekSelectors.
        Dim hasWeekSelectors As Boolean = Me.HasWeekSelectors(System.Web.UI.WebControls.CalendarSelectionMode.DayWeek)
        ' Call the base OnPreRender method.
        MyBase.OnPreRender(e)
    End Sub
End Class
注解
值CalendarSelectionModeDayWeek和DayWeekMonth两者都包含周选择器。