Greetings all:
I have an asp.net application that is coded mainly in vb.net. I have
successfully cut and pasted some javascript into my application that
mimicks the datetime picker control in vb. I wanted to try to use that
same code for another popup style window that displays a list of
airport codes in a datagrid. The desired results would be that when an
airport code (the datagrid's key field) is clicked the value would
write back to the parent page's textbox.
So far I have been able to get the popup window to display but when I
click on an airport code in the datagrid the window does not close nor
does the value write back to the parent page control.
Parent page HTML that opens the popup:
<TD>
<SPAN id="aircode1">
<A style="FONT-SIZE: xx-small"
href="Javascrip t:AirCode_windo w=window.open('/AdvTravel/AirCode.aspx?fo rmname=document .AdminBookingTD etails.txtTDDpt From','AirCode_ window',
'width=400');Ai rCode_window.fo cus()">Airport Code</A>
</SPAN>
</TD>
<TD>
<asp:TextBox id="txtTDDptFro m" runat="server"> </asp:TextBox>
</TD>
Popup window HTML that displays the airport codes and is supposed to
writeback the code:
<HTML>
<HEAD>
<title>US Airport Codes</title>
<script runat="server">
Private Sub dgdAirCodes_Ite mCommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
dgdAirCodes.Ite mCommand
Dim strjscript As String = "<script language=""java script"">"
strjscript = strjscript & "window.opener. " &
HttpContext.Cur rent.Request.Qu eryString("form name") & ".value = '" &
Server.UrlEncod e(dgdAirCodes.D ataKeys(e.Item. ItemIndex).ToSt ring) &
"';window.close ();"
strjscript = strjscript & "</script" & ">" 'Don't Ask, Tool Bug
Literal2.Text = strjscript
End Sub
</script>
</HEAD>
<body MS_POSITIONING= "FlowLayout ">
<form id="AirCode" method="post" runat="server">
<TABLE width="400">
<tr>
<td><asp:dropdo wnlist id="ddlState" runat="server" Width="136px"
AutoPostBack="T rue"></asp:dropdownlis t><asp:textbox id="Literal2"
runat="server"> </asp:textbox></td>
</tr>
<tr>
<td>
<asp:datagrid id="dgdAirCodes " runat="server" PageSize="50"
Font-Size="XX-Small" GridLines="Vert ical" CellPadding="3"
BackColor="Whit e" BorderWidth="1p x" BorderStyle="No ne"
BorderColor="#9 99999" AutoGenerateCol umns="False" AllowSorting="T rue"
OnItemCommand=" dgdAirCodes_Ite mCommand">
<FooterStyle ForeColor="Blac k"
BackColor="#CCC CCC"></FooterStyle>
<SelectedItemSt yle Font-Bold="True" ForeColor="Whit e"
BackColor="#008 A8C"></SelectedItemSty le>
<AlternatingIte mStyle
BackColor="Gain sboro"></AlternatingItem Style>
<ItemStyle ForeColor="Blac k"
BackColor="#EEE EEE"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="Whit e"
BackColor="#000 084"></HeaderStyle>
<Columns>
<asp:ButtonColu mn Text="Code" DataTextField=" Code"
SortExpression= "Code" HeaderText="Air port Code">
<HeaderStyle HorizontalAlign ="Center" Width="30px"></HeaderStyle>
<ItemStyle HorizontalAlign ="Center"></ItemStyle>
</asp:ButtonColum n>
*****Unnecessar y datagrid details removed********
<HeaderStyle Width="150px"></HeaderStyle>
</asp:BoundColumn >
</Columns>
<PagerStyle HorizontalAlign ="Center" ForeColor="Blac k"
Position="TopAn dBottom" BackColor="#999 999"
Mode="NumericPa ges"></PagerStyle>
</asp:datagrid></td>
</tr>
</TABLE>
</form>
</body>
</HTML>