473,769 Members | 6,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calendar Control ID unexpected result

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 version of the application. The
javascript version worked nicely -- you click on a calendar.gif in an anchor
next to a textbox. The calender would pop up in a new window, you select the
date, the calendar window would close and the textbox would be populated
with the date. All without making a return trip to the server... very nice.

I was having trouble getting the old javascript to run by passing the code
from the anchor
href="javascrip t:show_calendar ('document.GetE lementById('txt UpDate2')');"
which was working fine in the ASP. I included the JS file that has the
show_calendar function.

So I am trying to use the VB 2005 Calendar control. I placed it in a User
Control, which appears in the Context area of a Master Page (like the rest
of the content). BTW, all the content is in the same user control, including
the just-added Calendar and the page uses a Master Page. Not too complicated
for a .NET app.

Well, I set the Calendar1 to style="visibili ty;hidden". Then I included
client side script
onclick="docume nt.getElementBy Id('Calendar1') .style.visibili ty='visible'.

I got a clientside error about "Object Required".
When I looked at the source in the browser I see that the ID for the
Calendar is now:
ctl00_Content1_ SearchEdit1_Cal endar1
Wow. I didn't expect that. Also I haven't read anything anywhere about how
drastically the ID of an element or control can be changed at the browser.

1. Is there an explanation for that particular ID? The name of my User
Control is SearchEdit.ascx . Is there a way to predict what the clientside Id
will become when the control is nested in so many ways? Please direct me to
an article or MSDN discussion of that sort of thing, if anyone can.

2. Is there a way to use the Calendar control so that it actually does what
the old Javascript used to do? That was actually very cool.

Thanks......
Mar 8 '07 #1
7 2371

to insure uniqueness the id includes it parents control id. all control
have a property called ClientID that is the id that will be rendered.

-- bruce (sqlwork.com)
John Kotuby wrote:
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 version of the application. The
javascript version worked nicely -- you click on a calendar.gif in an anchor
next to a textbox. The calender would pop up in a new window, you select the
date, the calendar window would close and the textbox would be populated
with the date. All without making a return trip to the server... very nice.

I was having trouble getting the old javascript to run by passing the code
from the anchor
href="javascrip t:show_calendar ('document.GetE lementById('txt UpDate2')');"
which was working fine in the ASP. I included the JS file that has the
show_calendar function.

So I am trying to use the VB 2005 Calendar control. I placed it in a User
Control, which appears in the Context area of a Master Page (like the rest
of the content). BTW, all the content is in the same user control, including
the just-added Calendar and the page uses a Master Page. Not too complicated
for a .NET app.

Well, I set the Calendar1 to style="visibili ty;hidden". Then I included
client side script
onclick="docume nt.getElementBy Id('Calendar1') .style.visibili ty='visible'.

I got a clientside error about "Object Required".
When I looked at the source in the browser I see that the ID for the
Calendar is now:
ctl00_Content1_ SearchEdit1_Cal endar1
Wow. I didn't expect that. Also I haven't read anything anywhere about how
drastically the ID of an element or control can be changed at the browser.

1. Is there an explanation for that particular ID? The name of my User
Control is SearchEdit.ascx . Is there a way to predict what the clientside Id
will become when the control is nested in so many ways? Please direct me to
an article or MSDN discussion of that sort of thing, if anyone can.

2. Is there a way to use the Calendar control so that it actually does what
the old Javascript used to do? That was actually very cool.

Thanks......

Mar 8 '07 #2
"John Kotuby" <jo***@powerlis t.comwrote in message
news:uS******** ******@TK2MSFTN GP05.phx.gbl...
href="javascrip t:show_calendar ('document.GetE lementById('txt UpDate2')');"
That's unlikely to work for three reasons:

1) Your single quotes and double quotes are inconsistent...

2) You mention that this is in a MasterPage, so the client-side ID of
txtUpdate2 will have been modified...

3) JavaScript, like C#, is case-sensitive, so GetElementById needs to be
getElementById. ..

href=show_calen dar('document.G etElementById(" <%=txtUpDate2.C lientID%>")');
Mar 8 '07 #3
"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:ea******** ******@TK2MSFTN GP03.phx.gbl...
3) JavaScript, like C#, is case-sensitive, so GetElementById needs to be
getElementById. ..

href=show_calen dar('document.G etElementById(" <%=txtUpDate2.C lientID%>")');
Therefore:
href=show_calen dar('document.g etElementById(" <%=txtUpDate2.C lientID%>")');

Sorry - hit the Enter button just too soon...-)
Mar 8 '07 #4
Thanks Bruce

"bruce barker" <no****@nospam. comwrote in message
news:Oe******** ******@TK2MSFTN GP05.phx.gbl...
>
to insure uniqueness the id includes it parents control id. all control
have a property called ClientID that is the id that will be rendered.

-- bruce (sqlwork.com)
John Kotuby wrote:
>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 version of the application.
The javascript version worked nicely -- you click on a calendar.gif in an
anchor next to a textbox. The calender would pop up in a new window, you
select the date, the calendar window would close and the textbox would be
populated with the date. All without making a return trip to the
server... very nice.

I was having trouble getting the old javascript to run by passing the
code from the anchor
href="javascri pt:show_calenda r('document.Get ElementById('tx tUpDate2')');"
which was working fine in the ASP. I included the JS file that has the
show_calenda r function.

So I am trying to use the VB 2005 Calendar control. I placed it in a User
Control, which appears in the Context area of a Master Page (like the
rest of the content). BTW, all the content is in the same user control,
including the just-added Calendar and the page uses a Master Page. Not
too complicated for a .NET app.

Well, I set the Calendar1 to style="visibili ty;hidden". Then I included
client side script
onclick="docum ent.getElementB yId('Calendar1' ).style.visibil ity='visible'.

I got a clientside error about "Object Required".
When I looked at the source in the browser I see that the ID for the
Calendar is now:
ctl00_Content1 _SearchEdit1_Ca lendar1
Wow. I didn't expect that. Also I haven't read anything anywhere about
how drastically the ID of an element or control can be changed at the
browser.

1. Is there an explanation for that particular ID? The name of my User
Control is SearchEdit.ascx . Is there a way to predict what the clientside
Id will become when the control is nested in so many ways? Please direct
me to an article or MSDN discussion of that sort of thing, if anyone can.

2. Is there a way to use the Calendar control so that it actually does
what the old Javascript used to do? That was actually very cool.

Thanks......


Mar 9 '07 #5
Thanks Mark,

I am trying the syntax at the bottom of your reply, but the VS 2005 IDE is
giving me an error about non-matching quotes.
Note: I am copying the actual source that is being shown on screen into this
post.

When I place quotes around the href attribute in the source code...

href="javascrip t:show_calendar ('document.getE lementById("<%= txtCreateDate.C lientID%>")')"

So that the VStudio error goes away (and the line
<%=txtCreateDat e.ClientID%show s up in red)

I get the browser error...

Public member 'ClientID' on type 'String' not found.

pointing to the line in the browser ...
<a
href="javascrip t:show_calendar ('document.getE lementById("<%= txtCreateDate.C lientID%>")')"
"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:Oe******** *****@TK2MSFTNG P04.phx.gbl...
"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:ea******** ******@TK2MSFTN GP03.phx.gbl...
>3) JavaScript, like C#, is case-sensitive, so GetElementById needs to be
getElementById ...

href=show_cale ndar('document. GetElementById( "<%=txtUpDate2. ClientID%>")');

Therefore:
href=show_calen dar('document.g etElementById(" <%=txtUpDate2.C lientID%>")');

Sorry - hit the Enter button just too soon...-)



Mar 9 '07 #6
"John Kotuby" <jo***@powerlis t.comwrote in message
news:ei******** *****@TK2MSFTNG P04.phx.gbl...
I am trying the syntax at the bottom of your reply, but the VS 2005 IDE is
giving me an error about non-matching quotes.
Note: I am copying the actual source that is being shown on screen into
this post.

When I place quotes around the href attribute in the source code...

href="javascrip t:show_calendar ('document.getE lementById("<%= txtCreateDate.C lientID%>")')"

So that the VStudio error goes away (and the line
<%=txtCreateDat e.ClientID%show s up in red)

I get the browser error...

Public member 'ClientID' on type 'String' not found.

pointing to the line in the browser ...
<a
href="javascrip t:show_calendar ('document.getE lementById("<%= txtCreateDate.C lientID%>")')"
Hmm - you might be able to fix it by escaping one of the pairs of quotes
e.g. \'.....\'

Another option, though a bit of a kludge, might be something like:

var objCreateDate = document.getEle mentById('<%=tx tCreateDate.Cli entID%>');
href="show_cale ndar(objCreateD ate)";

You seem to keep putting "javascript :" back in...
Also, you seem to keep removing the semi-colon from the end of the line...
Mar 9 '07 #7
Thanks Mark...
I keep putting the javascript: part back in because that is what was in the
original ASP and I thought it was necessary to use as the value for the
href= whereas the onclick= attribute allows direct calling of the javascript
function. I understand that if I include the Runat="Server" that the syntax
would need to change to OnClientClick=.

Here is some code in context as viewed from the server side error message:
----------------------------
Exception Details: System.MissingM emberException: Public member 'ClientID'
on type 'String' not found.

<td nowrap="nowrap" >
Line 400: <input type="text" class="smallCbo 2"
name="txtCreate Date" id="txtCreateDa te" value="<%=txtCr eateDate%>" />
Line 401: <a
href="javascrip t:show_calendar ('document.getE lementById('<%= txtCreateDate.C lientID%>')');"
onmouseover="wi ndow.status='Da te Picker';return true;"
Line 402: onmouseout="win dow.status='';r eturn
true;">
Line 403: <img alt="Calendar"
src="../../images/show-calendar.gif" width="17" height="16" border="0"
/></a>
---------------------------------

Note that I have not declared these particular controls as runat=server.
This page is a very complicated mixture of controls for putting together a
long search query for SQL Server. For now I am trying to port most of the
markup as-is until I understand better how the original Author of the ASP
program made it work. Then when time allows, convert the coding to primarily
server controls in ASP.NET 2.0. The page renders fine until I try running
the clientsidejavas cript.

Note that line 400 value=<%=txtCre ateDate %reneders fine and does not
cause an error.

Oops... I may now see what's happening. I had created a VB string variable
txtCreateDate which happens to have the same name as the ID of the input
control. I will change the ID of the input control to txtCreateDate1 and see
if that helps.

I am also wondering if using the ID of the control for in-line VB is correct
syntax as in ControlId.Clien tId. Most of the Online help shows an example of
first declaring an Instance of the control in order to get to the ControlID
property. Sure would be nice if the short-hand version worked.

I guess I will find out soon. I am also going to try assembling the strings
into a variable as you suggested. Maybe in the Code Behind in Page_Init.

.... John
"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:ei******** ******@TK2MSFTN GP03.phx.gbl...
"John Kotuby" <jo***@powerlis t.comwrote in message
news:ei******** *****@TK2MSFTNG P04.phx.gbl...
>I am trying the syntax at the bottom of your reply, but the VS 2005 IDE
is giving me an error about non-matching quotes.
Note: I am copying the actual source that is being shown on screen into
this post.

When I place quotes around the href attribute in the source code...

href="javascri pt:show_calenda r('document.get ElementById("<% =txtCreateDate. ClientID%>")')"

So that the VStudio error goes away (and the line
<%=txtCreateDa te.ClientID%sho ws up in red)

I get the browser error...

Public member 'ClientID' on type 'String' not found.

pointing to the line in the browser ...
<a
href="javascri pt:show_calenda r('document.get ElementById("<% =txtCreateDate. ClientID%>")')"

Hmm - you might be able to fix it by escaping one of the pairs of quotes
e.g. \'.....\'

Another option, though a bit of a kludge, might be something like:

var objCreateDate =
document.getEle mentById('<%=tx tCreateDate.Cli entID%>');
href="show_cale ndar(objCreateD ate)";

You seem to keep putting "javascript :" back in...
Also, you seem to keep removing the semi-colon from the end of the line...

Mar 9 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4319
by: Charles | last post by:
Hello, I would like for my users to have a calendar control only when needed. IE button click for the control to appear and then once the date is selected. Populate a text box and the calendar control then is invisible. How do I make the calendar control pop up over other control in a asp.net c# environment? Charles
5
4600
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 Color 3. Foreground Color 4. Border Tickness 5. Border Color
2
3417
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 controls (i.e. roundedcorners component www.4guysfromrolla.com], buttons and panels) functions like a tab control. The buttons are programmatically designed to make the corresponding panel visible. Sample aspx.vb code:
1
1376
by: MattB | last post by:
Hi. I posted yesterday about being able to get to Day.IsSelecteable from outside the calendar's DayRender event. I never figured that out, so I found another way to do what I needed by externalizing the logic that sets the calendar days as selectable or not and using that same logic elsewhere. I thought I had the problem solved, but I noticed something unexpected. When I change the selected date in the calendar by clicking on it, my...
0
1252
by: sakieboy | last post by:
I'm working with ASP.Net 1.1. I have a user control that displays a javascript/DHTML calendar (because the normal calendar is clunky-real estate issue). I am using Microsoft.Web.UI.Webcontrols for the Tabstrip. On the first tab I have a date user control, it works.... when I select next to proceed to the next tab, I write the information to the DB(SQL) because I need the ID. I have a date user control on the second tab, when I select...
0
1774
by: jphelan | last post by:
After opening and clicking on the popup calendar command control button, "fdlgCal"; I click on a given date. The date is suppose to then appear in a date field next to the control. Instead, I get the following error: "Microsoft Office Access The expression On Click you entered as the event property setting produced the following error: The expression you
4
2965
by: ShyGuy | last post by:
A while back I had found a link to a popup calendar that had a small button that was placed to the right of any text box. By clicking on the icon and selecting a date the text box was updated with that date. You were able to use the icon (button) on multiple text boxes on the form. I have lost the link and can't find any reference to it on my machine. Could someone lead me in the right direction? Thank you.
3
2742
by: thorpk | last post by:
I posted this problem earlier in the month and some one decided it was better to change the subject and ask a completely different question. I am therefore reposting. I am hoping some one can assist with this. Thanks in advance. I have an access database that i have added a pop up calendar to, the Table information for the Date Reported field is Date/Time format short date, input mask is 00/00/0000.
0
3327
by: mathewgk80 | last post by:
HI all, I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page.... I would like to get the code for connecting the javascript to asp.net page... Please help me... The javascript code is as follows..
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9999
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.