dropdown calendar control with HTML <INPUT> control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sreenath Rao Nellutla
    New Member
    • Apr 2007
    • 5

    dropdown calendar control with HTML <INPUT> control

    Hai all,

    I am trying to create dropdown calendar control with HTML input control by writing JavaScript. But while executing I am getting the error as "Error on Page" on the status bar of the browser. I wrote the following code in the HTML code for the web form:

    <%@ Page language="c#" Codebehind="Web Form2.aspx.cs" AutoEventWireup ="false" Inherits="calen dar.WebForm2" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <script type="text/javascript">
    <!--
    function onClick()
    {
    if (divCalendar.st yle .display ="none")
    divCalendar.sty le .display ="";
    else
    divCalendar.sty le .display ="none";
    }
    //-->
    </script>

    <title>WebForm2 </title>
    <meta content="Micros oft Visual Studio .NET 7.1" name="GENERATOR ">
    <meta content="C#" name="CODE_LANG UAGE">
    <meta content="JavaSc ript" name="vs_defaul tClientScript">
    <meta content="http://schemas.microso ft.com/intellisense/ie5" name="vs_target Schema">
    </HEAD>
    <body MS_POSITIONING= "GridLayout " onload ="hello()">
    <form id="Form1" method="post" runat="server">
    <DIV id="divCalendar " style="Z-INDEX: 104; LEFT: 392px; WIDTH: 256px; POSITION: absolute; TOP: 144px; HEIGHT: 216px"
    ms_positioning= "FlowLayout"><a sp:textbox id="TextBox1" runat="server"> </asp:textbox><INPUT id="onClick" onclick ="onClick()" type="button" value="Call function">
    <asp:calendar id="Calendar1" runat="server" Visible="False" ></asp:calendar></DIV>
    <asp:button id="Button1" style="Z-INDEX: 102; LEFT: 184px; POSITION: absolute; TOP: 8px" runat="server"
    Text="Button"></asp:button></form>
    <noscript>
    This browser does not support script</noscript>
    </body>
    </HTML>

    If I use webserver button control instead of HTML input control and I write the following code

    private void Button1_Click(o bject sender, System.EventArg s e)
    {
    if(Calendar1.Vi sible ==true)
    Calendar1.Visib le =false;
    else
    Calendar1.Visib le =true;
    }


    in the button click event, then it is working fine.
    My requirement is the calendar control is to be displayed when I click the HTML Input control. If I click once again it should disappear.
    Please help me where I am doing mistake while writing JavaScript.
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    This question is being moved to the HTML forum.

    ADMIN

    Comment

    • drhowarddrfine
      Recognized Expert Expert
      • Sep 2006
      • 7434

      #3
      Moved to asp.

      Comment

      Working...