在Asp.net应用程序中显示日历内容

时间:2014-03-17 16:27:49

标签: c# asp.net ajax calendar ajaxcontroltoolkit

我有一个Asp.net应用程序,我想在其中添加a calendar extendar。所以我使用这段代码:

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Home.aspx.vb" Inherits="Home" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <cc1:ToolkitScriptManager   ID="ScriptManager1" runat="server" EnableScriptGlobalization="true"></cc1:ToolkitScriptManager>

        <span  style=" margin-left: 60%">
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="error1" Text="error1" ControlToValidate="FirstDate" ForeColor="Red" Font-Bold="true"></asp:RequiredFieldValidator>
       <asp:RegularExpressionValidator ID="RegularExpressionValidator1"  runat="server" ErrorMessage="error2" Text="error2" ControlToValidate="FirstDate"  ValidationExpression="^[0-3]+[0-9]\/[0-1]+[0-9]\/[0-9]{4}" ForeColor="Red" Font-Bold="true"></asp:RegularExpressionValidator>
        <asp:TextBox ID="FirstDate" runat="server"   ></asp:TextBox> 
            <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="FirstDate" CssClass="test">
            </cc1:CalendarExtender>
        </span>
</asp:Content>

问题是:当我点击TextBox时,日历不会显示:

  • 为什么会这样?
  • 如何修改我的代码以修复此错误?

1 个答案:

答案 0 :(得分:1)

我不相信CalendarExtender表现得像你期待的那样。至少,它不适合我。我通常做的是添加ImageButton并使CalendarExtender's PopupButtonID等于ImageButton's ID。