473,396 Members | 1,833 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.

Problem when opening popup window in ajax

139 100+
Hai all,

Is any body know ajax?
Sep 10 '07 #1
40 2919
acoder
16,027 Expert Mod 8TB
Post your problem code. What's supposed to happen and what's happening instead? What errors do you get, if any?
Sep 10 '07 #2
dmjpro
2,476 2GB
Hai all,

Is any body know ajax?
Let me know first how much u know AJAX?

Kind regards,
Dmjpro.
Sep 10 '07 #3
bhappy
139 100+
Hai all,

Thanks for replay. I want to create a popup window when i select ' add new' in dropdown list.iam using the following code.
Expand|Select|Wrap|Line Numbers
  1. url = "var W=window.open('" + url + "','Country','width=350,height=200,toolbar=no,menubar=no, scrollbars=no status=yes'); W.moveTo(110,30); W.focus(); "
  2.  
  3.  Response.Write("<script> " + url.ToString + "</script>")
  4.  
Before that for binding dropdown list details im using AJAX code.Now the problem here is Popup window is not opening?
Sep 10 '07 #4
acoder
16,027 Expert Mod 8TB
Threads merged. Please do not double post.

Also remember to use code tags when posting code.
Sep 10 '07 #5
bhappy
139 100+
Hi all,

Any Answer to my problem.

Thanks,
Aswath.
Sep 10 '07 #6
dmjpro
2,476 2GB
Hai all,

Thanks for replay. I want to create a popup window when i select ' add new' in dropdown list.iam using the following code.
Expand|Select|Wrap|Line Numbers
  1. url = "var W=window.open('" + url + "','Country','width=350,height=200,toolbar=no,menubar=no, scrollbars=no status=yes'); W.moveTo(110,30); W.focus(); "
  2.  
  3.  Response.Write("<script> " + url.ToString + "</script>")
  4.  
Before that for binding dropdown list details im using AJAX code.Now the problem here is Popup window is not opening?
What is Response.Write.
Please Exaplin.

Kind regards,
Dmjpro.
Sep 10 '07 #7
acoder
16,027 Expert Mod 8TB
Before that for binding dropdown list details im using AJAX code.Now the problem here is Popup window is not opening?
This code will not work because it is called while the page is loading.

Put it inside a function and then call that function onchange. Check that the selected value is "add new".
Sep 10 '07 #8
acoder
16,027 Expert Mod 8TB
What is Response.Write.
I'm assuming Response.Write is ASP which is why I used ASP code tags.
Sep 10 '07 #9
bhappy
139 100+
Hi,

Response.write() means it will open new popup window. If i don't use ajax
to bind dropdown list details then popup window is opened for the same code what i listed above. But if i use AJAX window is not opening why?

Thanks,
Aswath.
Sep 10 '07 #10
acoder
16,027 Expert Mod 8TB
Response.write() means it will open new popup window. If i don't use ajax to bind dropdown list details then popup window is opened for the same code what i listed above. But if i use AJAX window is not opening why?
Post the rest of your code.
Sep 10 '07 #11
bhappy
139 100+
Hi,

This is the entire code what iam using to create popup window.
Expand|Select|Wrap|Line Numbers
  1. url="country.aspx"
  2.  If a = "Add New" Then
  3.  url = "var W=window.open('" + url + "','Country','width=350,height=200,toolbar=no,menubar=no, scrollbars=no status=yes'); W.moveTo(110,30); W.focus(); "
  4.         Response.Write("<script> " + url.ToString + "</script>")
  5.  
  6.             End If
  7.  
Same code works for without AJAX. If i use AJAX This code is not working .Why?

Thanks,
Aswath.
Sep 10 '07 #12
acoder
16,027 Expert Mod 8TB
Show your Ajax code and how you call it using the dropdown.

PS. use code tags when posting code.
Sep 10 '07 #13
bhappy
139 100+
Hi,

I will explain what my intension is, In my aspx page i have 3 dropdown lists country, state, city.If i select one country then related states will bind on state dropdown list. same for city also.

Without AJAX ::
I put country & state dpd's autopostback=true And to create popup window im using the above code.Then it successfully creating window.


With AJAX ::

I used ajax code to bind state & city details .So i got o/p without loading the page.But for creating popup window also im using the same code what i used above.But it is not working.
Sep 10 '07 #14
acoder
16,027 Expert Mod 8TB
See post #8 in this thread. You will need to put it in a function and call that onchange (on the select element).
Sep 10 '07 #15
bhappy
139 100+
Hi,
Thanks,
I did what You told yestraday.I put my code in seperate function.Now The popup window is opening.But now i am getting other problem that i want to close that child window, for that iam using " Child.window.close()" method. but it is not closing.And I didn't get the details in dropdown list of my parent window.Why?



Thanks,
Aswath.
Sep 11 '07 #16
acoder
16,027 Expert Mod 8TB
I did what You told yestraday.I put my code in seperate function.Now The popup window is opening.But now i am getting other problem that i want to close that child window, for that iam using " Child.window.close()" method. but it is not closing.And I didn't get the details in dropdown list of my parent window.Why?
Show your updated code.

You need to keep a reference to the opened window by, e.g.
Expand|Select|Wrap|Line Numbers
  1. var child = window.open(...);
Sep 11 '07 #17
bhappy
139 100+
Hi,
Thanks a lot, Now window is closing by creating reference.But i can't get the data of child window into my parent window.My parent window dropdownlist becomes empty.Any ideas....?

Thanks,
Aswath.
Sep 11 '07 #18
acoder
16,027 Expert Mod 8TB
Show the code which populates the list.
Sep 11 '07 #19
bhappy
139 100+
Hi,

Code:.net
After Addibg One country im populating state details .
Expand|Select|Wrap|Line Numbers
  1.  Dim sql1 As String = "select name as cstate,sid as id from master_state where cid = '" & cid & "' order by name for xml auto"
  2.                 com = New SqlCommand(sql1, con)
  3.                 dr = com.ExecuteReader()
  4.                 If dr.HasRows Then
  5.                     If dr.Read Then
  6.                         s.Append(dr.GetString(0).Trim())
  7.                     End If
  8.             Response.ContentType = "Text/xml"
  9.  
  10.                 Response.Write("<States>" + s.ToString())
  11.  
In This time no states in newly added country so it display empty in state dropdown list, but in country dropdown list also it showing empty.Why?

Thanks,
Aswath.
Sep 11 '07 #20
bhappy
139 100+
Hi All,

Any Answer to my problem?

thanks,
Aswath.
Sep 11 '07 #21
acoder
16,027 Expert Mod 8TB
In This time no states in newly added country so it display empty in state dropdown list, but in country dropdown list also it showing empty.Why?
Show the Javascript code that updates the state dropdown list.

Also remember to use code tags when posting code.
Sep 11 '07 #22
bhappy
139 100+
Dear Acoder,

I againg coming with new query, first of all thanks a lot u helped me more.All of my previous problems are rectified.After selecting "Add New" in dropdown list
The popup window is opening, But The problem is after the popup window is closing(autometically) the parent window is reloading to get the newly added details(country).But what my client needed is that the newly added value shuld be disply in that dropdownlist(country)

so plz help me.
Sep 12 '07 #23
bhappy
139 100+
Hi All,

Any Answer to my query....?



Thanks,
Aswath.
Sep 12 '07 #24
bhappy
139 100+
Hi,

Once the popup window is closed the parent window is reloading autometically in ajax why..?

Thanks,
Sep 12 '07 #25
acoder
16,027 Expert Mod 8TB
Again, you'll have to show the code. Post your Javascript code (not .NET code). If there's a lot of code and it's possible, post a link to a test page instead.
Sep 12 '07 #26
bhappy
139 100+
Hi,
Iam Sorry,Still im not upload my project.and the AJAX code contains more than 600 lines,for all ie., creating popup window's for new country, new state, and new city.as well as binding state & city details after country dpd list has changed. So The problem is Once i create new country or state or city the parent window is reloaded and i lost the details on my parent window ie.,(company name, address etc...all textboxes).I need to enter the details once again in textboxes.


Thanks,
Aswath.
Sep 12 '07 #27
acoder
16,027 Expert Mod 8TB
Locate the code which creates the country, state and city dropdown lists and just post that here.
Sep 12 '07 #28
bhappy
139 100+
Hi Acoder,

Here is code to create new country.
Code:(AJAX) ---- For New Country ------

Expand|Select|Wrap|Line Numbers
  1. if(cid=="Add New")
  2.     {
  3.      if (obj!=null )
  4.             {
  5.             obj.onreadystatechange = n;  
  6.                var url="Country.aspx"; 
  7.                     var W=window.open(url,'Country','width=400,height=200,toolbar=no,menubar=no, resizable=yes,scrollbars=yes status=yes');      
  8.                 W.focus();
  9. }
  10. }
  11.  function n()
  12.           {
  13.            var c_id=document.getelementbyid("id");
  14.            if (obj!=null )
  15.             {
  16.             obj.onreadystatechange = contry;  
  17.              obj.open("GET","../getcontact.aspx?id="+c_id+"&status=4",true);
  18.  
  19.             obj.send(null); 
  20.           }
  21.    }
  22.  
  23.  function contry()
  24.     {
  25.     if(obj.readyState == 4)
  26.     { 
  27.         if (obj.status == 200)
  28.         {
  29.             retval = ""
  30.             var retval = obj.responseText;                
  31.             retval += "</countries>"
  32.             clearSelect(document.getElementById("dpdcontry"));            
  33.             populatecntry(retval)        
  34.         }
  35.         else
  36.           {
  37.             alert('error');    
  38.           }
  39.         }
  40.     }   


And remaning code is comman that is getting 'httprequestobject' .

Thanks,
Aswath.
Sep 12 '07 #29
bhappy
139 100+
Hai,

What's Happened.......?Can u understand my code.I thin no. Ok tell me how to store the page contents tempororly? I made all my controls to "EnableViewState=True" Then also i m not able to persist the details.


Thanks,
Aswath.
Sep 12 '07 #30
bhappy
139 100+
Hi Acoder,

I got the error ,but i don't know solution.The problem is here
Expand|Select|Wrap|Line Numbers
  1. Response.Write("<Script language='JavaScript' type='text/javascript'>opener.location='Company.aspx?id=" + c_id + "';self.close(); </Script>")
Here im sending newly created Country_id to company.aspx page(parent).That's why parent window is reloading to get newly created country.Now tell me is there any way to reload only dropdownlist?
I tryed like
" dpdcontry.opener.location.reload(). " But it doesn,t works. U r my only hope

Thanks,
Aswath.
Sep 12 '07 #31
acoder
16,027 Expert Mod 8TB
Hi Acoder,

Here is code to create new country.
On line 13, it should be document.getElementById().

Show the code for clearSelect and populateCntry functions.
Sep 12 '07 #32
acoder
16,027 Expert Mod 8TB
Hi Acoder,

I got the error ,but i don't know solution.The problem is here
Expand|Select|Wrap|Line Numbers
  1. Response.Write("<Script language='JavaScript' type='text/javascript'>opener.location='Company.aspx?id=" + c_id + "';self.close(); </Script>")
Here im sending newly created Country_id to company.aspx page(parent).That's why parent window is reloading to get newly created country.Now tell me is there any way to reload only dropdownlist?
I tryed like
" dpdcontry.opener.location.reload(). " But it doesn,t works. U r my only hope
To update the dropdown list, access the element using opener.document.getElementById(). Don't use location or reload(). That would just reload the page.
Sep 12 '07 #33
bhappy
139 100+
Hi
Here is the code for populate contry & clearselect
Code:(AJAX)
Expand|Select|Wrap|Line Numbers
  1. function populatecntry(response)
  2.   {
  3.  // var con_id=document.getElementById ("dpdcontry").value 
  4.         var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")//Create the XMLDOM object
  5.         xmlDoc.async = false
  6.         xmlDoc.loadXML(response)        
  7.             var opt
  8.             var cityselem = xmlDoc.getElementsByTagName("countries")
  9.             var cityelem = cityselem[0].getElementsByTagName("master_country")
  10.             var opt = document.createElement("option")
  11.             opt.setAttribute("value",-1)
  12.             //var textnode = document.createTextNode ("Select Country")
  13.             opt.appendChild(textnode)
  14.               document.getElementById ("dpdcontry").appendChild(opt)                            
  15.     for (var i = 0;i<cityelem.length ;i++)
  16.     {
  17.     var textnode = document.createTextNode (cityelem[i].getAttribute("name"))
  18.     //alert(stateelem[i].getAttribute("cstate"))
  19.     appendtoselectcntry( document.getElementById ("dpdcontry"),cityelem[i].getAttribute("cid"),textnode)    
  20.     }            
  21.    } 
  22.  
  23.  
  24.  
  25. function clearSelect(select)
  26.     {
  27.     //alert(document.getElementById ("dpdcontry"));
  28.     //alert(select);
  29.      select.options.length = 0;
  30. }
  31.  
I listed in previous post that in javascript is there nay way to reload only dropdownlis?

Thanks,
Aswath.
Sep 12 '07 #34
acoder
16,027 Expert Mod 8TB
I listed in previous post that in javascript is there nay way to reload only dropdownlis?
You don't need to reload anything. Just access the element from the child window:
Expand|Select|Wrap|Line Numbers
  1. var dropdown = opener.document.getElementById("dpdcontry");
Then reset it by setting options.length to 0. Then update the list by adding options using the response (XML). Remember that you can add an option using syntax like:
Expand|Select|Wrap|Line Numbers
  1. dropdown.options[i] = new Option('text','value');
Sep 12 '07 #35
bhappy
139 100+
Hi Acoder,

I tried with your code, Here im getting dropdown value as "Add New"
I am not getting newly added country value.
Code:<Javascript>
var dropdown =opener.document.getElementById("dpdcontry");

I am closing popup window in CodeBehind of child page, and im retriving new value in html of parent page.that's why im getting "add new" only.If i pass new value in child window to parent window then i can get value but the entire window is reloading.I tried like
code:<JS>
Opener.location.reload(false)=company.aspx"+c_id"
it is showing error.Is there any other way?


Thanks,
Aswath.
Sep 13 '07 #36
bhappy
139 100+
Hi Acoder,

Any Answer to my problem........?


Thanks,
Aswath.
Sep 13 '07 #37
acoder
16,027 Expert Mod 8TB
Why do you need the "Add New" option to open a popup window? Can you not just make the Ajax call in the parent window?
Sep 13 '07 #38
bhappy
139 100+
Hi Acoder,

How is it possible?After selecting "add new" in dropdown list then in ajax one property is there "Onreadystatechange".Im using this property to create popup windw.I know only this way. Is there any other way..?


Thanks,
Aswath.
Sep 13 '07 #39
bhappy
139 100+
Hi Acoder,

Thank you, from 4 days u r with me and resolved my doubts.The last problem i given to my Team Lead.Now im doing seperate work.If i will get any errors again i will discuss with u.Ok Thanks a lot.

Bye

Aswath.
Sep 13 '07 #40
hi frnds

ur asking about why response.write is not working with ajax,this problem come to me too,. we cant write anything in browser throw response.write() because of script manager will not support.

for more details
http://siderite.blogspot.com/2007/02/aspnet-ajax-and-responsewrite-or.html
Sep 17 '07 #41

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

Similar topics

6
by: Tony G. | last post by:
Hi there, I have an APS 3 application, running on a Windows 2003 Web edition server - it is a very busy website, and when users are click on certain links (membership info), a new window i...
0
by: melanieab | last post by:
Hi, I can't begin to understand this one. I have a form with a tabcontrol. When I first enter one of the pages (whether by tabbing or opening the form), I say to focus on a button. It does focus...
0
by: ravitunk | last post by:
can anyone tell me how to open a popup window(.aspx page) on Mouse Rollover...everytime cursor is moved to a row of a gridview..this should also send a parameter to the popup window....where the...
1
by: =?Utf-8?B?bWF2cmljazEwMQ==?= | last post by:
Hi, I have a page which has some custom controls. The page works fine and doesn't break on any number of refreshes. There is button on the page, that starts a new child window. After doing any...
3
by: siva07 | last post by:
<SCRIPT language=JavaScript type=text/javascript> <!-- function open1(URL) { popupWin = window.open(URL, 'popup', 'dependent=0,...
1
by: SangeethaAyyappan | last post by:
Hi, I have an application which requires a help window to pop-up, whenever the user clicks the 'Lookup' button. Everything works fine, except that the pop-up window displays for the first two...
4
rizwan6feb
by: rizwan6feb | last post by:
Hi experts! I getting the following error message from Firefox, for the given code Error: uncaught exception: Permission denied to get property Window.resizeTo <!DOCTYPE html PUBLIC...
2
by: rkyakkala | last post by:
Hi, i am creating a popupwindow example.After entering the details i want to close the parent window(details.html)as it is moving to new window.could anybody suggest how can i do both task at a time...
1
by: Alon Stadler | last post by:
Hi, I'm trying to luanch a new window with Java Script - It works fine in Chrome and Firefox, but not with IE (I'm using IE8) or Avant browser. The page is at...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.