M
maxrawson
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="Javascript:AirCode_window=window.open('/AdvTravel/AirCode.aspx?formname=document.AdminBookingTDetails.txtTDDptFrom','AirCode_window',
'width=400');AirCode_window.focus()">Airport Code</A>
</SPAN>
</TD>
<TD>
<asp:TextBox id="txtTDDptFrom" 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_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgdAirCodes.ItemCommand
Dim strjscript As String = "<script language=""javascript"">"
strjscript = strjscript & "window.opener." &
HttpContext.Current.Request.QueryString("formname") & ".value = '" &
Server.UrlEncode(dgdAirCodes.DataKeys(e.Item.ItemIndex).ToString) &
"';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:dropdownlist id="ddlState" runat="server" Width="136px"
AutoPostBack="True"></asp:dropdownlist><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="Vertical" CellPadding="3"
BackColor="White" BorderWidth="1px" BorderStyle="None"
BorderColor="#999999" AutoGenerateColumns="False" AllowSorting="True"
OnItemCommand="dgdAirCodes_ItemCommand">
<FooterStyle ForeColor="Black"
BackColor="#CCCCCC"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#008A8C"></SelectedItemStyle>
<AlternatingItemStyle
BackColor="Gainsboro"></AlternatingItemStyle>
<ItemStyle ForeColor="Black"
BackColor="#EEEEEE"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White"
BackColor="#000084"></HeaderStyle>
<Columns>
<asp:ButtonColumn Text="Code" DataTextField="Code"
SortExpression="Code" HeaderText="Airport Code">
<HeaderStyle HorizontalAlign="Center" Width="30px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:ButtonColumn>
*****Unnecessary datagrid details removed********
<HeaderStyle Width="150px"></HeaderStyle>
</asp:BoundColumn>
</Columns>
<PagerStyle HorizontalAlign="Center" ForeColor="Black"
Position="TopAndBottom" BackColor="#999999"
Mode="NumericPages"></PagerStyle>
</asp:datagrid></td>
</tr>
</TABLE>
</form>
</body>
</HTML>
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="Javascript:AirCode_window=window.open('/AdvTravel/AirCode.aspx?formname=document.AdminBookingTDetails.txtTDDptFrom','AirCode_window',
'width=400');AirCode_window.focus()">Airport Code</A>
</SPAN>
</TD>
<TD>
<asp:TextBox id="txtTDDptFrom" 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_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgdAirCodes.ItemCommand
Dim strjscript As String = "<script language=""javascript"">"
strjscript = strjscript & "window.opener." &
HttpContext.Current.Request.QueryString("formname") & ".value = '" &
Server.UrlEncode(dgdAirCodes.DataKeys(e.Item.ItemIndex).ToString) &
"';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:dropdownlist id="ddlState" runat="server" Width="136px"
AutoPostBack="True"></asp:dropdownlist><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="Vertical" CellPadding="3"
BackColor="White" BorderWidth="1px" BorderStyle="None"
BorderColor="#999999" AutoGenerateColumns="False" AllowSorting="True"
OnItemCommand="dgdAirCodes_ItemCommand">
<FooterStyle ForeColor="Black"
BackColor="#CCCCCC"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#008A8C"></SelectedItemStyle>
<AlternatingItemStyle
BackColor="Gainsboro"></AlternatingItemStyle>
<ItemStyle ForeColor="Black"
BackColor="#EEEEEE"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White"
BackColor="#000084"></HeaderStyle>
<Columns>
<asp:ButtonColumn Text="Code" DataTextField="Code"
SortExpression="Code" HeaderText="Airport Code">
<HeaderStyle HorizontalAlign="Center" Width="30px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:ButtonColumn>
*****Unnecessary datagrid details removed********
<HeaderStyle Width="150px"></HeaderStyle>
</asp:BoundColumn>
</Columns>
<PagerStyle HorizontalAlign="Center" ForeColor="Black"
Position="TopAndBottom" BackColor="#999999"
Mode="NumericPages"></PagerStyle>
</asp:datagrid></td>
</tr>
</TABLE>
</form>
</body>
</HTML>