By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,857 Members | 1,835 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,857 IT Pros & Developers. It's quick & easy.

javascript popup conflict

P: n/a
I'm having a problem with two different javascript controls in my app.
The first chuck of javascript that I pasted into my app is the
client-side calendar control popup which works fine when first used.
The second piece of javascript pasted into the app serves as a data
validation message box that fires after some server-side code executes
(if a certain error condition exists). This action is tied to a
submit button that upon NO error condition would write the data to
SQL. The calendar controls work fine until the other server-side
javascript executes then the calendar controls will pop up but when
you click on a date the window does not go away and the selected date
does not populate the textbox it is assigned to.

NOTE: VS.NET 2003 environment

HTML FROM PAGE THAT UTILIZES CALENDAR POP-UP:

<asp:TextBox id="txtStartDt" runat="server"
Width="85px"></asp:TextBox>
<SPAN id="calBlock1">
<A href="javascript:calendar_window=window.open('/advtravel/calendar.aspx?formname=frmNewTrvlReq.txtStartDt',' calendar_window','width=230,height=230');calendar_ window.focus()"><IMG
height="16" alt="Choose A Log Date" src="images/calendar.gif"
width="18" align="absMiddle" border="0"></A>
</SPAN>

CALENDAR.ASPX HTML:

<HTML>
<HEAD>
<title>Select a date</title>
<script runat="server">
Private Sub cntCalendar_SelectionChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cntCalendar.SelectionChanged

Dim strjscript As String = "<script language=""javascript"">"
strjscript = strjscript & "window.opener." &
HttpContext.Current.Request.QueryString("formname" ) & ".value = '" &
cntCalendar.SelectedDate & "';window.close();"
strjscript = strjscript & "</script" & ">"
Literal1.Text = strjscript

End Sub
</script>

<asp:literal id="Literal1" Runat="server"></asp:literal>
<LINK href="http://localhost/AdvTravel/CSS/calendar.css"
type="text/css" rel="stylesheet">
</HEAD>
<BODY bgcolor="silver">
<form id="frmCalendar" runat="server">
<cc1:roundedcorners id="RoundedCorners1" runat="server"
Width="190px" BorderColor="Navy" BorderStyle="Solid" BorderWidth="2px"
CornerHeight="20px" CornerWidth="20px" Height="190px"
BackColor="WhiteSmoke">
<TABLE cellSpacing="0" cellPadding="0" align="center">
<TR>
<TD height="13">
<asp:dropdownlist id="drpCalMonth" Runat="Server" Width="100px"
AutoPostBack="True" OnSelectedIndexChanged="Set_Calendar"
CssClass="calTitle"></asp:dropdownlist>
<asp:dropdownlist id="drpCalYear" Runat="Server"
Width="60px" AutoPostBack="True" OnSelectedIndexChanged="Set_Calendar"
CssClass="calTitle"></asp:dropdownlist>
</TD>
</TR>
<TR>
<TD>
<asp:calendar id="cntCalendar" Runat="Server" Width="100%"
CssClass="calbody" DayStyle-BackColor="LightYellow"
OtherMonthDayStyle-BackColor="White"
OnSelectionChanged="cntCalendar_SelectionChanged" ShowTitle="True"
ondayrender="Calendar_dayrender"></asp:calendar>
</TD>
</TR>
</TABLE>
</cc1:roundedcorners>
</form>
</BODY>
</HTML>

SERVER-SIDE DATA VALIDATION CODE :

Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click

StartDate = txtStartDt.Text
EndDate = txtEndDt.Text
startTime = wsdataformat.DDL2Military(ddlStartTime.SelectedVal ue)
EndTime = wsdataformat.DDL2Military(ddlEndTime.SelectedValue )

Select Case EndDate

Case Is < StartDate
Dim strScript As String = "<script
language=Javascript>"
strScript += "alert(""" & "INVALID DATE RANGE." & "\n"
& "\n" & "The END DATE cannot occur before the START DATE." & "\n" &
"\n" & "Please re-enter the dates." & """);"
strScript += "</script>"

If (Not Page.IsStartupScriptRegistered("ErrorScript"))
Then
Page.RegisterStartupScript("ErrorScript",
strScript)
Exit Sub
End If

Case Is = StartDate
If EndTime < startTime Then
Dim strScript As String = "<script
language=Javascript>"
strScript += "alert(""" & "INVALID TIMES." & "\n"
& "\n" & "The END TIME cannot occur before the START TIME." & "\n" &
"\n" & "Please re-enter the TIMES." & """);"
strScript += "</script>"

If (Not
Page.IsStartupScriptRegistered("ErrorScript")) Then
Page.RegisterStartupScript("ErrorScript",
strScript)
End If
Exit Sub
End If
Submit_Validated()

Case Is > StartDate

Submit_Validated()

End Select

End Sub
Any help in regards to this matter would be greatly appreciated.

-Maxwell

****If there is a better way to accomplish either of the tasks
described I would definitely be open to hear about redesign options.
Thanks in advance****
Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.