Problem when opening popup window in ajax

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bhappy
    New Member
    • Jul 2007
    • 139

    #31
    Hi Acoder,

    I got the error ,but i don't know solution.The problem is here
    [Code=Javascript]
    Response.Write( "<Script language='JavaS cript' type='text/javascript'>ope ner.location='C ompany.aspx?id= " + c_id + "';self.close() ; </Script>")[/code]

    Here im sending newly created Country_id to company.aspx page(parent).Th at'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.opene r.location.relo ad(). " But it doesn,t works. U r my only hope

    Thanks,
    Aswath.
    Last edited by acoder; Sep 12 '07, 01:58 PM. Reason: fixed code tags

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #32
      Originally posted by bhappy
      Hi Acoder,

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

      Show the code for clearSelect and populateCntry functions.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #33
        Originally posted by bhappy
        Hi Acoder,

        I got the error ,but i don't know solution.The problem is here
        [Code=Javascript]
        Response.Write( "<Script language='JavaS cript' type='text/javascript'>ope ner.location='C ompany.aspx?id= " + c_id + "';self.close() ; </Script>")[/code]

        Here im sending newly created Country_id to company.aspx page(parent).Th at'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.opene r.location.relo ad(). " 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.

        Comment

        • bhappy
          New Member
          • Jul 2007
          • 139

          #34
          Hi
          Here is the code for populate contry & clearselect
          Code:(AJAX)
          [CODE=javascript]function populatecntry(r esponse)
          {
          // var con_id=document .getElementById ("dpdcontry").v alue
          var xmlDoc=new ActiveXObject(" Microsoft.XMLDO M")//Create the XMLDOM object
          xmlDoc.async = false
          xmlDoc.loadXML( response)
          var opt
          var cityselem = xmlDoc.getEleme ntsByTagName("c ountries")
          var cityelem = cityselem[0].getElementsByT agName("master_ country")
          var opt = document.create Element("option ")
          opt.setAttribut e("value",-1)
          //var textnode = document.create TextNode ("Select Country")
          opt.appendChild (textnode)
          document.getEle mentById ("dpdcontry").a ppendChild(opt)
          for (var i = 0;i<cityelem.le ngth ;i++)
          {
          var textnode = document.create TextNode (cityelem[i].getAttribute(" name"))
          //alert(stateelem[i].getAttribute(" cstate"))
          appendtoselectc ntry( document.getEle mentById ("dpdcontry"),c ityelem[i].getAttribute(" cid"),textnode )
          }
          }



          function clearSelect(sel ect)
          {
          //alert(document. getElementById ("dpdcontry" ));
          //alert(select);
          select.options. length = 0;
          }
          [/CODE]
          I listed in previous post that in javascript is there nay way to reload only dropdownlis?

          Thanks,
          Aswath.
          Last edited by acoder; Sep 12 '07, 03:33 PM. Reason: Added code tags

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #35
            Originally posted by bhappy
            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:
            [CODE=javascript]var dropdown = opener.document .getElementById ("dpdcontry" );[/CODE] 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:[CODE=javascript]dropdown.option s[i] = new Option('text',' value');[/CODE]

            Comment

            • bhappy
              New Member
              • Jul 2007
              • 139

              #36
              Hi Acoder,

              I tried with your code, Here im getting dropdown value as "Add New"
              I am not getting newly added country value.
              Code:<Javascrip t>
              var dropdown =opener.documen t.getElementByI d("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.

              Comment

              • bhappy
                New Member
                • Jul 2007
                • 139

                #37
                Hi Acoder,

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


                Thanks,
                Aswath.

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #38
                  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?

                  Comment

                  • bhappy
                    New Member
                    • Jul 2007
                    • 139

                    #39
                    Hi Acoder,

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


                    Thanks,
                    Aswath.

                    Comment

                    • bhappy
                      New Member
                      • Jul 2007
                      • 139

                      #40
                      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.

                      Comment

                      • hajaworld
                        New Member
                        • Sep 2007
                        • 2

                        #41
                        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.blogsp ot.com/2007/02/aspnet-ajax-and-responsewrite-or.html

                        Comment

                        Working...