473,396 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Pass parent value to pop-up...

145 100+
1. This works great.
Expand|Select|Wrap|Line Numbers
  1.    <a href="javascript:void(0)" onclick="window.open('adddept.aspx','welcome','width=400,height=250')">Add a Department </a>
2. I am trying to Pass a value "txtParentID" to pop up window "txtChildID"

I found a java for the second item. but how do I get # 1 to execute the java function after it opens up pop up window.


http://aspadvice.com/blogs/azamsharp...nt-Window.aspx
Mar 27 '09 #1
14 3636
dorandoran
145 100+
Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:void(0)" onclick="window.open('Assign_Dept.aspx?value = " + txtParent.Text + " ','welcome','width=400,height=250')">
  2.                                             Assign Dept test</a>
theParent.Text is in red and it tells me is not a valid attribute of a. what would be the right syntax?
Mar 28 '09 #2
gits
5,390 Expert Mod 4TB
the first param in the window.open() method should look like this:

Expand|Select|Wrap|Line Numbers
  1. 'Assign_Dept.aspx?value = \"' + txtParent.Text + '\"'
kind regards
Mar 28 '09 #3
dorandoran
145 100+
Hi gits, I tried your suggession but still nothing happens when I click on the button.

This is my textbox
Expand|Select|Wrap|Line Numbers
  1. <asp:TextBox ID="txtParent" runat="server" ></asp:TextBox></td>
Here is the href
Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:void(0)" onclick="window.open('Assign_Dept.aspx?value = \"' + txtParent.Text + '\"','welcome','width=400,height=250')">
  2.                                             Assign Dept test</a>
Any help will be truly appreciated as I spend more than 8 hours on this.
Mar 28 '09 #4
gits
5,390 Expert Mod 4TB
when you call:

Expand|Select|Wrap|Line Numbers
  1. alert('Assign_Dept.aspx?value = \"' + txtParent.Text + '\"');
in your onclick handler, does the alert show you the correct url?

kind regards
Mar 28 '09 #5
dorandoran
145 100+
This works but I need to pass value.
Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:void(0)" onclick="window.open('Assign_Dept.aspx','welcome','width=400,height=250')">Assign Dept.&nbsp;</a>
Mar 28 '09 #6
gits
5,390 Expert Mod 4TB
did the alert work?

kind regards
Mar 28 '09 #7
dorandoran
145 100+
Alert works on the first href but does not work on the 2nd href.

Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:void(0)" onclick="alert('Assign_Dept.aspx','welcome','width=400,height=250')">Assign Dept.&nbsp;</a>
  2. <br /> 
  3. <br />
  4.  <a href="javascript:void(0)" onclick="window.open('Assign_Dept.aspx?value = \"' + txtParent.Text + '\"','welcome','width=400,height=250')">
  5.                                             Assign Dept test</a>
Mar 28 '09 #8
gits
5,390 Expert Mod 4TB
try the following ... we separate the build of the url here:

Expand|Select|Wrap|Line Numbers
  1. onclick="var url = 'Assign_Dept.aspx?value = \"' + txtParent.Text + '\"';  window.open(url,'welcome','width=400,height=250')"
this should work otherwise please tell what value the variable has ...

kind regards
Mar 28 '09 #9
dorandoran
145 100+
Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:void(0)" onclick="var url = 'Assign_Dept.aspx?value = \"' + txtParent.Text + '\"';  window.open(url,'welcome','width=400,height=250')" >
  2.                                         Assign Dept </a>
Not working. Nothing happens.
txtParent.text has integer (string to be correct) in it. I am populating this text box when I select a row from a gridview. and I can see it's been populated after i select a row.
Expand|Select|Wrap|Line Numbers
  1.     protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
  2.     {
  3.                 txtParent.Text = GridView2.SelectedValue.ToString();
  4.     }
Mar 28 '09 #10
gits
5,390 Expert Mod 4TB
ahhhrg .... tried it myself now and we get an unterminatetd string-literal at the first double quote, just try it without concatenating the double quotes:

Expand|Select|Wrap|Line Numbers
  1. var url = 'Assign_Dept.aspx?value=' + txtParent.Text;
as far as i'm aware you don't need them, and in case you do we could try the encodeURIComponent() method, since it seems that in the onclick the escape of the double quotes didn't work. you could even write a function in an extra script-block and call the function in your onclick, that would circumvent this silly problem.

kind regards
Mar 29 '09 #11
dorandoran
145 100+
I am going to give up after 3 day mission on this. Thanks gits for keeping up with me and helping me.
Mar 29 '09 #12
gits
5,390 Expert Mod 4TB
the last suggestions i gave above should work ... personally i would prefer the function wrapper way. just put a function like below in a script section in the head of your page:

Expand|Select|Wrap|Line Numbers
  1. function openMyWindow() {
  2.     var url = 'foo.html?value="' + myValue + '"';
  3.  
  4.     window.open(url, // more params here);
  5. }
now in your onclick handler just call:

Expand|Select|Wrap|Line Numbers
  1. onclick="openMyWindow()"
it's a too small problem to just give up ;) ...

kind regards
Mar 29 '09 #13
dorandoran
145 100+
gits,

Thanks for keeping up with me on this. I understand what you said about not giving up. Thanks for keeping me up and not give up.

Guess what. it FINALLY WORKED. I am posting the final code in case someone wants to implement this.

parent.aspx

1. Put this script before head (form1 is the name of my form where txtParent form is located
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" language="javascript">
  2. function openMyWindow() { 
  3.     var myValue = form1.txtParent1.value
  4.     var url = 'PopUp.aspx?value=' + myValue + ''; 
  5.  
  6.     window.open(url);   // more params here, like width, height, etc.
  7. </script>
2. This is my Click Text (you can use button)
Expand|Select|Wrap|Line Numbers
  1.     <a href="javascript:void(0)" onclick="openMyWindow()">Open Pop - Bytes</a>
3. popup.aspx , put this code on the pageload of popup.aspx
Expand|Select|Wrap|Line Numbers
  1.             string strP = Request["value"].ToString();
  2.             txtPopup2.Text = strP;
ALL THE THANKS TO gits because he has lots of patience and never gave up on me. Thank you gits.
Mar 30 '09 #14
gits
5,390 Expert Mod 4TB
glad to hear you got it working ;) ... in case you would have more questions just post back to the forum ;)

kind regards,
gits
Mar 30 '09 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: DamonChong | last post by:
Hi, I am still struggling to master C++ and is trying to understand how to achieve passing arguments using pointers. I got some questions that I like to post to the experts here, hope you can...
3
by: DCB | last post by:
Hello. I have an easy question, likely, that has me in a headspin. I have an include file to a frames based site that basically forces frames on the end user if they visit the site and hit a...
3
by: Peter | last post by:
I have a webform on this form is a User Control and another webform in IFRAME On the User Control there is a save button. I want to click this button and somehow tell the webpage in IFRAME that...
0
by: ab_j | last post by:
I have a user control that contains a dropdown which I want to use as a menu on multiple .aspx pages. Basically, all I am trying to do is pass the selected value of the dropdown in the user...
8
by: darrel | last post by:
I'm still trying to fully understand how best to pass variables between pages/usercontrols/each other. On a current site I've done, I've had one userControl do the logic and set the variable,...
6
by: kath | last post by:
hi everyone......... I have a task, I have fragmented the task into subtask. I have planned to create a class to each subclass and one parent class to handle the sub tasks. Each subclass are...
8
by: BigZero | last post by:
Hello, i need to pass some variables or value to javascript from php script. well all i need to pass to value to javascript that is with in same php file the two values r in php i need to pass...
5
by: Rob | last post by:
I have a control (Button) on a Parent form which opens a Windows form... all I want to do is pass a value from the child form back to the parent... it should be so simple... i.e....
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.