By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,115 Members | 734 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,115 IT Pros & Developers. It's quick & easy.

dropdown calendar control with HTML <INPUT> control

P: 5
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.
May 10 '07 #1
Share this Question
Share on Google+
2 Replies

MMcCarthy
Expert Mod 10K+
P: 14,534
This question is being moved to the HTML forum.

ADMIN
May 10 '07 #2

drhowarddrfine
Expert 5K+
P: 7,435
Moved to asp.
May 11 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.