473,396 Members | 1,917 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,396 software developers and data experts.

Calendar pop-up won't return value in Firefox

I created a pop-up window using the ASP.NET 2.0 calendar in a distinct
file (calpopup.aspx). The calendar pops up when clicking on a
linkbutton and copies the selected day back into the textbox. This
works fine in IE.

In Firefox however, while the calendar is displayed correctly, the date
is not copied back. The console javascript reports the error:
'window.opener.document.forms is not a function'.

How can I trick FF into executing the script? Thanks for any advice,
Mark

Event that fires after a day is clicked (calpopup.aspx):

Protected Sub Change_Date(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim cs As ClientScriptManager = Page.ClientScript
Dim cstype As Type = Me.GetType()
Dim cskey As String = "Test-CalPopup"

Dim strScript As String =
"<script>window.opener.document.forms(0)." + control.Value + ".value =
'"
strScript += calDate.SelectedDate.ToString("dd/MM/yy")
strScript += "';self.close()"
strScript += "</" + "script>"

If Not
ClientScript.IsClientScriptBlockRegistered("Test-CalPopup") Then
cs.RegisterClientScriptBlock(cstype, cskey, strScript)
End If
End Sub

Aug 1 '06 #1
5 2200
Er... FF is right, forms is not a function and forms(0) is therefore an
invalid function call.

Tried forms[0] ?
ms******@bluewin.ch wrote:
I created a pop-up window using the ASP.NET 2.0 calendar in a distinct
file (calpopup.aspx). The calendar pops up when clicking on a
linkbutton and copies the selected day back into the textbox. This
works fine in IE.

In Firefox however, while the calendar is displayed correctly, the date
is not copied back. The console javascript reports the error:
'window.opener.document.forms is not a function'.

How can I trick FF into executing the script? Thanks for any advice,
Mark

Event that fires after a day is clicked (calpopup.aspx):

Protected Sub Change_Date(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim cs As ClientScriptManager = Page.ClientScript
Dim cstype As Type = Me.GetType()
Dim cskey As String = "Test-CalPopup"

Dim strScript As String =
"<script>window.opener.document.forms(0)." + control.Value + ".value =
'"
strScript += calDate.SelectedDate.ToString("dd/MM/yy")
strScript += "';self.close()"
strScript += "</" + "script>"

If Not
ClientScript.IsClientScriptBlockRegistered("Test-CalPopup") Then
cs.RegisterClientScriptBlock(cstype, cskey, strScript)
End If
End Sub
Aug 1 '06 #2
I always use getElementById() when I set values of controls with javascript.

Try:
"window.opener.document.getElementById('" + control.Value + "').value;"

instead of
window.opener.document.forms(0)." + control.Value + ".value

//Mats

ms******@bluewin.ch wrote:
I created a pop-up window using the ASP.NET 2.0 calendar in a distinct
file (calpopup.aspx). The calendar pops up when clicking on a
linkbutton and copies the selected day back into the textbox. This
works fine in IE.

In Firefox however, while the calendar is displayed correctly, the date
is not copied back. The console javascript reports the error:
'window.opener.document.forms is not a function'.

How can I trick FF into executing the script? Thanks for any advice,
Mark

Event that fires after a day is clicked (calpopup.aspx):

Protected Sub Change_Date(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim cs As ClientScriptManager = Page.ClientScript
Dim cstype As Type = Me.GetType()
Dim cskey As String = "Test-CalPopup"

Dim strScript As String =
"<script>window.opener.document.forms(0)." + control.Value + ".value =
'"
strScript += calDate.SelectedDate.ToString("dd/MM/yy")
strScript += "';self.close()"
strScript += "</" + "script>"

If Not
ClientScript.IsClientScriptBlockRegistered("Test-CalPopup") Then
cs.RegisterClientScriptBlock(cstype, cskey, strScript)
End If
End Sub
Aug 1 '06 #3
You can also put a javascript function in the parent window

javascript:window.opener.myJavaScriptFunction(2006 ,8,3);

where myJavaScriptFunction (on the parent) would have 3 arguments, of
year,mm,day

see
http://www.mattkruse.com/javascript/calendarpopup/

for other options.


<ms******@bluewin.chwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
I created a pop-up window using the ASP.NET 2.0 calendar in a distinct
file (calpopup.aspx). The calendar pops up when clicking on a
linkbutton and copies the selected day back into the textbox. This
works fine in IE.

In Firefox however, while the calendar is displayed correctly, the date
is not copied back. The console javascript reports the error:
'window.opener.document.forms is not a function'.

How can I trick FF into executing the script? Thanks for any advice,
Mark

Event that fires after a day is clicked (calpopup.aspx):

Protected Sub Change_Date(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim cs As ClientScriptManager = Page.ClientScript
Dim cstype As Type = Me.GetType()
Dim cskey As String = "Test-CalPopup"

Dim strScript As String =
"<script>window.opener.document.forms(0)." + control.Value + ".value =
'"
strScript += calDate.SelectedDate.ToString("dd/MM/yy")
strScript += "';self.close()"
strScript += "</" + "script>"

If Not
ClientScript.IsClientScriptBlockRegistered("Test-CalPopup") Then
cs.RegisterClientScriptBlock(cstype, cskey, strScript)
End If
End Sub

Aug 1 '06 #4
Thanks for the reply, Flinky. Changing (0) to [0] does the trick!

When I use this function in a multi-page master/details environment, I
am getting IE script errors. For instance, if I want to copy the
calendar value in, say, textbox 'Prjs_BegDay' of script 'Prjs.aspx',
the following error pops up:

'window.opener.document.forms.0.Prjs_BegDay is null or is not an
object'

I suppose the runtime/browser does not know how/where to locate the
textbox. How would I modify the function to solve this?

TIA, Mark

Aug 1 '06 #5
The referencing problem is related to the master/details model.

After looking at the browser source and some searching, I found out
that in a master/detail configuration, control IDs do change to sthg
like:

<ID of Master Page Control>$<ID of Content Place Holder>$Text1 control>

For example in a details form, the textbox ID="Prjs_BegDay" typically
changes to:
name="ctl00$CONTENT$Prjs_BegDay" id="ctl00_CONTENT_Prjs_BegDay"

So, to properly reference controls, I came up with the following
heuristic solution. However, I don't know if this approach is correct.

Step 1. I added an init event to consistently rename the master ID as
'Master'.

Step 2. I substitued all IDs of the controls invoked by javascript
functions by their extended IDs noting the placeholders where they are
located in. For example, if control 'id="Prjs_StartDay"' is located in
contentplaceholder 'CONTENT', it will be invoked in a js function as
'id="Master_CONTENT_Prjs_BegDay"'.

The following now works:

<asp:TextBox ID="Prjs_BegDay" runat="server"...>
<a href="javascript:;"
onclick="window.open('calpopup.aspx?id=Master_CONT ENT_Prjs_BegDay',...>

Please advise if this is correct. TIA, Mark

Aug 1 '06 #6

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

Similar topics

2
by: Zlatko Matić | last post by:
Hello. I have unbounded textboxes for input start/end date criteria. I would like to have a calendar control that pop-ups when someone is trying to input criteria. How to do it ? Thanks.
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...
5
by: Peter | last post by:
Is it possible to span / display a graphic in the web calendar control that spans more than one cell / day? Does anyone have an example of this? Thanks Peter
6
by: Sridhar | last post by:
Hi, I need to display a calendar that shows all the months of an year. In that, I need to show different colors for certain events. I know how to display a calendar for a certain month but I am...
0
by: sangmin.park | last post by:
Hello. I made a page using .net calendar. At first, I build this page with 3 frames. "top", "menu", "main" "menu" frame has page links and .net calendar. Now, the page was revised to use...
9
by: Greg | last post by:
Hi, I have a table with "dates", i'd like to display those dates on a calendar. I've put a calendar in a form, linked to my "date" field, and it works, but only showing one "date" per calendar....
14
by: magmike | last post by:
Can I do anything with the calendar buttons? I want to display a number on the buttons. I'm using the calendar control on a form that sets a call back date and time. The user can click on the...
3
by: Andrus | last post by:
I need that WinForms DateTimePicker opens calendar when F12 key is pressed. I tried code below but got error Property or indexer 'System.Windows.Forms.KeyEventArgs.KeyCode' cannot be assigned to...
7
by: William (Tamarside) | last post by:
Please, if you have the time and knowledge to help me I'd truly appreciate it! I need to build a calendar page that displays available/unavailable info from a DB and colour a cell according to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.