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

How to access ASP.NET Calendar control from javascript?

P: n/a
Ben
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

May 19 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
The calendar's UNIQUEID might differ on render try :

document.getElementById('<%=Calender1.uniqueid%>') .style.visibility
='visible';

(You might need to modify to make it work)

"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

May 19 '06 #2

P: n/a
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

May 19 '06 #3

P: n/a
Better to use ClientID instead of UniqueID - uniqueId names controls with a
'.' as a seperator instead of a '_'.

"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


May 25 '06 #4

P: n/a
Ben
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


Jun 7 '06 #5

P: n/a
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
>

Jun 8 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.