Sharepoint 2010 sharepoint datetime控件ClearSelection方法在OnDateChanged事件中不起作用

Sharepoint 2010 sharepoint datetime控件ClearSelection方法在OnDateChanged事件中不起作用,sharepoint-2010,Sharepoint 2010,我正在Visual web部件中使用SharePoint DateTimeControl。在这里,我检查所选日期不应为未来日期,为此,如果用户输入了未来日期,我将使用ScriptManager.RegisterStartupScript显示该警报消息。这些活动在OnDateChanged事件下处理。当我显示alert msg并使用ClearSelection()方法从DateTimecontrol清除所选日期时,它不会清除该值。下面我粘贴了我的代码 在设计方面: <SharePoint:D

我正在Visual web部件中使用SharePoint DateTimeControl。在这里,我检查所选日期不应为未来日期,为此,如果用户输入了未来日期,我将使用ScriptManager.RegisterStartupScript显示该警报消息。这些活动在OnDateChanged事件下处理。当我显示alert msg并使用ClearSelection()方法从DateTimecontrol清除所选日期时,它不会清除该值。下面我粘贴了我的代码

在设计方面:

<SharePoint:DateTimeControl ID="dtManagerJoiningDate" runat="server" AutoPostBack="true"
                    DateOnly="true" OnDateChanged="dtManagerJoiningDate_OnDateChanged" />

请在这方面帮助我……

我能够使用更新面板和脚本管理器复制该问题

我无法告诉您原因,但我通过将clearSelection代码放入OnPreRender

bool _clearSelection = false
protected void dtManagerJoiningDate_OnDateChanged(object sender, EventArgs e)
{
    if (dtManagerJoiningDate.IsValid)
    {
        if (dtManagerJoiningDate.SelectedDate > todayDate)
        {
           _clearSelection = true;
        }
    }
 }

    protected override void OnPreRender(EventArgs e)
    {
        //see if it clear selection is set
        if(_clearSelection)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Invalid Date",           "alert('Joining Date should be past Date');", true);
            dtManagerJoiningDate.ClearSelection();
         }
    }

我能够使用更新面板和脚本管理器复制该问题

我无法告诉您原因,但我通过将clearSelection代码放入OnPreRender

bool _clearSelection = false
protected void dtManagerJoiningDate_OnDateChanged(object sender, EventArgs e)
{
    if (dtManagerJoiningDate.IsValid)
    {
        if (dtManagerJoiningDate.SelectedDate > todayDate)
        {
           _clearSelection = true;
        }
    }
 }

    protected override void OnPreRender(EventArgs e)
    {
        //see if it clear selection is set
        if(_clearSelection)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Invalid Date",           "alert('Joining Date should be past Date');", true);
            dtManagerJoiningDate.ClearSelection();
         }
    }

你能试着把它放在警告信息之前吗?你能试着把它放在警告信息之前吗?