473,387 Members | 1,863 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,387 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 10769
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.