需要在单击textbox时显示日历calendar1,
已有的代码是
load form中放了
this.TextBox2.Attributes.Add("onclick ","ShowCalendar()"); web页中加了
<script language="javascript"> 
function ShowCalendar() 
{
    请问这里需要什么语句??
}
</script> 

解决方案 »

  1.   

    一般
    document.getElementById("calendar1").style.display=""
      

  2.   

    <%@ Page Language="C#" EnableViewState="true" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">  protected void Page_Load(object sender, EventArgs e)
      {
        Calendar1.Attributes.Add("style", "display:none");
      }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
      <title></title>
      <script>
          function Show() {
            document.getElementById("<%=Calendar1.ClientID %>").style.display = "";
          }
          function Hide() {
            document.getElementById("<%=Calendar1.ClientID %>").style.display = "none";
          }
      </script>
    </head>
    <body>
      <form id="form1" runat="server">
     
      <asp:TextBox ID="TextBox1" runat="server" onclick="Show()" onblur="Hide()"></asp:TextBox>
      <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
     
      </form></body>
    </html>
      

  3.   

    页面
    <asp:Calendar ID="Calendar1" runat="server" style="display:none;"></asp:Calendar>js
    <script language="javascript">  
    function ShowCalendar()  
    {
      //请问这里需要什么语句??
      document.getElementById("Calendar1").style.display = "block";
    }
    </script>  
      

  4.   

    在Web页中,放置<asp:Calendar ID="Calendar1" style="display: none;" runat="server"></asp:Calendar>控件,设置STYLE属性.
    JS CODE:
    <script language="javascript">  
    function ShowCalendar()  
    {
      document.getElementById("Calendar1").style.display = "";
    }
    </script> 
      

  5.   

    请问,你是想ShowCalendar()函数用来显示当前日期吗?
      

  6.   

    C# CODE:
    protected void Page_Load(object sender, EventArgs e)
        {
    this.Textbox2.Attributes.Add("onclick ", "ShowCalendar();");
    this.Calendar1.Attributes.Add("onclick", "SetValue();");
        }JS CODE:
    function SetValue()
    {
        document.getElementById("Textbox2").value = document.getElementById("Calendar1").;
    }