2011-09-06 49 views
0

我试图做一个日历弹出时,按钮(...)被点击,但我卡住,不知道我必须做什么。以下是我正在使用的代码。我使用visual studio 2010和C#作为我的编程语言。点击按钮时,我需要做什么来显示日历?

<asp:textbox id="TextBox1" runat="server"></asp:textbox> 
<input type="button" id="Button2" runat="server" value="...."><br> 
<asp:Panel id="pnlCalendar" runat="server" 
    style="POSITION: absolute"> 
<asp:calendar id="Calendar3" runat="server" CellPadding="4" 
     BorderColor="#999999" Font-Names="Verdana" Font-Size="8pt" 
     Height="180px" ForeColor="Black" DayNameFormat="FirstLetter" 
     Width="200px" BackColor="White"> 
    <TodayDayStyle ForeColor="Black" BackColor="#CCCCCC"></TodayDayStyle> 
    <SelectorStyle BackColor="#CCCCCC"></SelectorStyle> 
    <NextPrevStyle VerticalAlign="Bottom"></NextPrevStyle> 
    <DayHeaderStyle Font-Size="7pt" Font-Bold="True" BackColor="#CCCCCC"> 
    </DayHeaderStyle> 
    <SelectedDayStyle Font-Bold="True" ForeColor="White" BackColor="#666666"> 
    </SelectedDayStyle> 
    <TitleStyle Font-Bold="True" BorderColor="Black" BackColor="#999999"> 
    </TitleStyle> 
    <WeekendDayStyle BackColor="LightSteelBlue"></WeekendDayStyle> 
    <OtherMonthDayStyle ForeColor="#808080"></OtherMonthDayStyle> 
</asp:calendar> 
</asp:Panel> 

This is generated with my code

回答

0

您可以考虑使用jQuery UI Date picker ...灵活,客户端和使用NuGet

安装的NuGet您VS并键入安装,包装jQuery.UI需要两分钟设置。合并

包括需要的JavaScript库,请按照示例,你很好去;)

+0

...我安装了NuGet。你能请指导我下一步我要做什么。感谢您的耐心 – mikespiteri

+1

我觉得这个网页有你需要的所有信息;)http://docs.nuget.org/docs/start-here/Using-the- Package-Manager-Console –

4

ASP.NET Calendar很难以这种方式使用。更简单的方法是使用或JQuery DatePicker

+1

我同意Ajax或JQuery会是更好的选择。 – MStp

0

如果你真的想在服务器端做到这一点,那么这是你可以做的。

bool showCalendar = false; 
protected void Page_Load(object sender, EventArgs e) 
{ 
    if (showCalendar) 
     Calendar1.Visible = true; 
    else 
     Calendar1.Visible = false; 
} 

protected void Button1_Click(object sender, EventArgs e) 
{ 
    Calendar1.Visible = true; 
} 

,基本建立Calendar.Visible对按钮假,当用户点击其设置为true,但一旦它被设置为true ..它是不是真的弹出,但使用回传

0

被添加控制当有人点击文本字段本身时,您可以做到这一点。

 <asp:Label ID="lblDate" runat="server" Text="Date :"></asp:Label> 
     <asp:TextBox ID="txtDate" runat="server" ></asp:TextBox> YYYY-MM-DD 
     <asp:CalendarExtender ID="CalendarExtender1" TargetControlID="txtDate" runat="server" Format="yyyy-MM-dd"> 
     </asp:CalendarExtender> 
相关问题