当前位置:编程学习 > C#/ASP.NET >>

梅花日历如何实现?

一个txtbox。一个按钮在asp.net中如何实现日历控件? --------------------编程问答-------------------- 给你写了一个。


前台
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="use.aspx.cs" Inherits="use" %>

<!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 runat="server">
    <title>Calendar</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       <table>
          <tr>
             <td>
             <asp:TextBox ID="TextBoxDate" runat="server"></asp:TextBox>
             <asp:Button ID="Button1" runat="server" Text="..." />
           
             </td>
          </tr>
          <tr>
             <td>
             <asp:Panel ID="PanelCalendar" runat="server" Visible="true">
             <asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged">
             </asp:Calendar>
        
        
             </asp:Panel>
        
             </td>
        
           </tr>
        
        </table>
    </div>
    </form>
</body>
</html>
后台

using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class use : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }



    public string Text
    {
        get
        {
            return this.TextBoxDate.Text;
        }
        set
        {
            this.TextBoxDate.Text = value;

        }
    }
    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        TextBoxDate.Text = Calendar1.SelectedDate.ToShortDateString();
        
    }
}

--------------------编程问答-------------------- 1楼的看清楚。 --------------------编程问答-------------------- js编写的日历控件网上很多啊,lz可以去下 一个,我也下过的,挺好用 --------------------编程问答--------------------
引用 3 楼 yymycabbage 的回复:
js编写的日历控件网上很多啊,lz可以去下 一个,我也下过的,挺好用


顶 --------------------编程问答--------------------
引用 1 楼 slund 的回复:
给你写了一个。


 前台
  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="use.aspx.cs" Inherits="use" %>

  <!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 runat="server">
      <title>Calendar </title>
  </head>
  <body>
      <form id="form1" runat="server">
      <div>
         <table>
            <tr>
               <td>
               <asp:TextBox ID="TextBoxDate" runat="server"> </asp:TextBox>
               <asp:Button ID="Button1" runat="server" Text="..." />

               </td>
            </tr>
            <tr>
               <td>
               <asp:Panel ID="PanelCalendar" runat="server" Visible="true">
               <asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged">
               </asp:Calendar>


               </asp:Panel>

               </td>

             </tr>

          </table>
      </div>
      </form>
  </body>
  </html>
 后台

 using System.Web.UI.WebControls.WebParts;
 using System.Web.UI.HtmlControls;

 public partial class use : System.Web.UI.Page
 {
     protected void Page_Load(object sender, EventArgs e)
     {

     }


     public string Text
     {
         get
         {
             return this.TextBoxDate.Text;
         }
         set
         {
             this.TextBoxDate.Text = value;

         }
     }
     protected void Calendar1_SelectionChanged(object sender, EventArgs e)
     {
         TextBoxDate.Text = Calendar1.SelectedDate.ToShortDateString();

     }
 }

试试
--------------------编程问答-------------------- 我也很想试试~~
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,