Popup window writeback problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • maxrawson@yahoo.com

    #1

    Popup window writeback problem

    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>

  • Randy Webb

    #2
    Re: Popup window writeback problem

    maxrawson@yahoo .com wrote:
    [color=blue]
    > 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>[/color]

    Instead of posting your ASP code, post the code that the browser gets.
    Then its a simple matter of copy/pasting to test it.

    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly

    Comment

    • RobG

      #3
      Re: Popup window writeback problem

      maxrawson@yahoo .com wrote:[color=blue]
      > 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.
      >[/color]

      Here is a trivial example:

      *************** *
      Parent window
      *************** *

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
      "http://www.w3.org/TR/html4/strict.dtd">
      <html>
      <head>
      <title>Window returns values</title>
      <meta http-equiv="Content-Type"
      content="text/html; charset=ISO-8859-1">
      <script type="text/javascript">
      // tgtElement: element to update (is also caller here)
      // winSource : the URL of the resource to load
      // theWindow : window object reference
      var theWindow;
      function openWindow(tgt, winSource) {
      theWindow = window.open(win Source,'',
      'top=300,left=7 00,width=300,he ight=100');

      // create a reference to the element to update in the
      // popup window
      theWindow.tgtEl ement = tgt;
      }
      </script>
      </head>
      <body onload="this.wi ndow.name = 'robWin';">
      <form name="winOpener ">
      <input type="text" name="dataField " onclick="
      openWindow(this ,'dataWindow.ht ml');
      ">
      <input type="reset" value="reset" onfocus="blur() ;">
      </form>
      </body>
      </html>



      *************** *
      Popup window (dataWindow.htm l)
      *************** *

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
      "http://www.w3.org/TR/html4/strict.dtd">
      <html>
      <head>
      <title>Data window</title>
      <meta http-equiv="Content-Type" content="text/html;
      charset=ISO-8859-1">
      </head>
      <body>
      <form action="">
      <select name="data">
      <option value="option01 " selected>Option 01</option>
      <option value="option02 ">Option 02</option>
      <option value="option03 ">Option 03</option>
      </select>
      <input type="button" value="Accept selected value" onclick="
      tgtElement.valu e =
      this.form.data[this.form.data. selectedIndex].value;
      window.close();
      ">
      </form>
      </body>
      </html>


      The only caveat is that opening a window this way in Firefox
      creates an error:

      Error: [Exception... "'Permissio n denied to get property
      XULElement.sele ctedIndex' when calling method: ...

      But the script runs OK. I can't find out how to prevent the
      error. IE seems quite happy.


      --
      Rob

      Comment

      Working...