Are you sure you're getting the right ID for the Calendar? If it's inside a
container control, it might have a different prefix. Here's a way to get the
ID for sure.
Let us know if this helps?
Ken
Microsoft MVP [ASP.NET]
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
ClientScript.RegisterClientScriptBlock _
(Me.GetType(), "cal", "function
valSubmit(){document.getElementById('" & _
Calendar1.ClientID & "').style.visibility='hidden';}", True)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Hide Calendar</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:calendar id="Calendar1" runat="server"></asp:calendar>
<br />
<button onclick="valSubmit();return false;">Hide</button></div>
</form>
</body>
</html>
"Ben" <wu******@yahoo.com> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
Hi Edwin,
The reason that I want to addess Calendar control in Javascript is
because I want to show and hide Calendar control without refreshing ASP
page.
I have a lot of database controls link to gridviews. Refreshing page
will take a long time.
Thanks,
Ben
Edwin Knoppert wrote: Btw, curious, how did you got the error?
"Ben" <wu******@yahoo.com> schreef in bericht
news:11**********************@u72g2000cwu.googlegr oups.com... >I have a javascript code in the ASP.NET page.
> I want to access Calendar control that is inside ASP page and is "run
> at server".
>
> I try to use following code but it doesn't work.
>
> <script language="javascript">
> function valSubmit()
> {
> document.getElementById("Calendar1").style.visibil ity =
> 'visible';
> }
> </script>
>
> I got following error:
>
> ERROR: Object required
>
> Could anyone give a suggestion?
>
> Thanks,
> Ben
>