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="javascript:show_calendar('document.GetElementById('txtUpDate2')');"
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="visibility;hidden". Then I included
client side script
onclick="document.getElementById('Calendar1').style.visibility='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_Calendar1
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......