473,320 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to access ASP.NET Calendar control from javascript?

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
5 10763
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: slawek xxxxx | last post by:
Hello everyone, I have a terrible with Calendar control and I hope someone of you can help me. The problem is following. I have to display a calendar to select date. I have prepared page with...
5
by: Miguel Dias Moura | last post by:
Hello, i am trying to create a .css file with several styles and apply them to the calendar control so i can change the look of: 1. Text Type and Format (Bold, Underline, etc) 2. Background...
0
by: maxrawson | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many...
2
by: Caesar Augustus | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many...
7
by: Mike Charney | last post by:
I am trying to use the calendar control in Access (Calendar Control 11.0) I have it working but for only one form. I do not know VB/VBA very well, but how can I open the calendar control, which...
1
by: afr0ninja | last post by:
Hello all, and thank you in advance for your assistance. I'm pretty new to access and I'm trying to teach myself some VBA by using various bits of code I find here and there mixed with my own....
3
by: =?Utf-8?B?UGFycm90?= | last post by:
I applied the following Ajax code in my web page which has a calendar control to keep my page from completely reloading everytime something was changed. <atlas:ScriptManager ID="ScriptManager1"...
7
by: John Kotuby | last post by:
Hi all, I am trying to use a calendar server control which I have ID="Calendar1" in the source code. What I am trying to do is emulate a JavaScript calendar that was being used in an older ASP...
2
by: phill86 | last post by:
Hi I have a calendar control (MS office Access calendar control 11.0) on my form and i want to refresh the form as soon as i have selected the date on the calendar any ideas? Cheers Phill
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.