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="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="calendar.WebForm2" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<script type="text/javascript">
<!--
function onClick()
{
if (divCalendar.style .display ="none")
divCalendar.style .display ="";
else
divCalendar.style .display ="none";
}
//-->
</script>
<title>WebForm2</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</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"><asp: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(object sender, System.EventArgs e)
{
if(Calendar1.Visible ==true)
Calendar1.Visible =false;
else
Calendar1.Visible =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.