Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / November 2007

Tip: Looking for answers? Try searching our database.

popup window: Return value to correct text box?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mel - 06 Nov 2007 18:28 GMT
Hi!  I have two text boxes and two image buttons.  When I click image
button 1 or 2  the same popup window is displayed (using 'window.open'
method).  When I click image button 1 the returning data from the
popup window is placed in text box 1 on the parent form.  When I click
image button 2 the returning data is placed in text box 1 also.  It
should be placed into text box #2 on the parent form.  How do I change
my javascript code so the data appears in the correct text box?

(using javascript, asp.net 2.0, vb.net)
bruce barker (sqlwork.com) - 06 Nov 2007 19:21 GMT
before calling window.open, set a global var to the textbox to update. then
in the popup, reference the global variable instead of the hardcoded textbox

-- bruce (sqlwork.com)

> Hi!  I have two text boxes and two image buttons.  When I click image
> button 1 or 2  the same popup window is displayed (using 'window.open'
[quoted text clipped - 5 lines]
>
> (using javascript, asp.net 2.0, vb.net)
Mel - 06 Nov 2007 21:29 GMT
On Nov 6, 1:21 pm, bruce barker (sqlwork.com)
<brucebarkersqlwork...@discussions.microsoft.com> wrote:
> before calling window.open, set a global var to the textbox to update. then
> in the popup, reference the global variable instead of the hardcoded textbox
[quoted text clipped - 10 lines]
>
> > (using javascript, asp.net 2.0, vb.net)

I am not sure how to do this in javascript.  Here is my code:

POPUP WINDOW (ASPX):
   <script language="javascript" type="text/javascript">
       function Done()
           {
          var Angle=document.getElementById('txtAng').value;
           var ret= new Array(Angle);
           window.opener.update(ret);
           window.close();
    }
   </script>
   <asp:TextBox ID="txtAng" runat="server" Width="48px"
BackColor="LemonChiffon" TabIndex="7" AutoPostBack="True"></
asp:TextBox>   'I want to store txtAng.Text value on popup window to
txtAng<#>.Text on parent window.
   <input id="cmdDone" type="button" onclick="Done();" value="Done"
tabindex="9" style="width:128px"/></td>

PARENT WINDOW (ASPX.VB file)
       OpenPopUp(imgAng1, "AngleCalc.aspx", "", 420, 250)  'OpenPopUp
subroutine just calls window.open method.  I just pass page name,
window height, width, etc.
       OpenPopUp(imgAng2, "AngleCalc.aspx", "", 420, 250)

PARENT WINDOW (ASPX file)
   <script language="javascript" type="text/javascript">
       function update(elemValue)
       {
       document.getElementById;
       document.getElementById('<%=txtAng1.ClientID
%>').innerText=elemValue[0];   'This always stores to txtAng1.Text.
How do I pass the text box index to here?
       }
   </script>
   <asp:TextBox AutoPostBack="True" BackColor="Black" Font-
Names="Verdana" Font-Size="Small" ForeColor="White" ID="txtAng1"
OnTextChanged="txtAng1_TextChanged" runat="server" TabIndex="15"
Width="49px"/>
   <asp:ImageButton ID="imgAng1" runat="server" ImageUrl="~/Images/
Ang.bmp" />
Mel - 07 Nov 2007 08:22 GMT
On Nov 6, 1:21 pm, bruce barker (sqlwork.com)
<brucebarkersqlwork...@discussions.microsoft.com> wrote:
> before calling window.open, set a global var to the textbox to update. then
> in the popup, reference the global variable instead of the hardcoded textbox
[quoted text clipped - 10 lines]
>
> > (using javascript, asp.net 2.0, vb.net)

I am not sure how to implement that in javascript.  Here is my code:

Parent Page_Load (aspx.vb file)
       OpenPopUp(imgAng1, "AngleCalc.aspx", "", 420, 250)  'calls
window.open (passes page name, height, width, etc.)
       OpenPopUp(imgAng2, "AngleCalc.aspx", "", 420, 250)

Parent javascript (aspx file)
   <script language="javascript" type="text/javascript">
       function update(elemValue)
       {
       document.getElementById;
       document.getElementById('<%=txtAng1.ClientID
%>').innerText=elemValue[0];   'writes to text box #1 all the time
       }
   </script>

Popup window javascript (aspx file)
   <script language="javascript" type="text/javascript">
       function Done()
       {
        var Angle=document.getElementById('txtAng').value;   'txtAng is a
text box on my popup window that I want to pass to txtAng<#>.Text in
my parent window
               var ret= new Array(Angle);
               window.opener.update(ret);
        window.close();
       }
   </script>
Mel - 07 Nov 2007 15:26 GMT
> On Nov 6, 1:21 pm, bruce barker (sqlwork.com)
>
[quoted text clipped - 43 lines]
>             }
>     </script>

Okay, I finally figured it out.  I added an OnClientClick method.
When a user clicks on an image button it calls a javascript function
which sets global variable and this variable is used in a select case
statement in my update function.

Anyone know why my javascript code does not work in Firefox?  The
popup window appears but the data is not returned to the parent
window.  I have javascript turned on in my Firefox settings and I am
not getting an error in the "Error Console".

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.