Updating textbox inside a TabPanels ContentTemplate

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GunnarJ
    New Member
    • Mar 2007
    • 7

    Updating textbox inside a TabPanels ContentTemplate

    I have an Ajax TabContainer. I also have a simple javascript function that normally can update a textbox using 'document.getEl ementById'
    This works as expected when the textbox is outside the TabPanel but when I move the exact same textbox inside a TabPanel the Javascript function does not seem to be able to reference it.
    The error reported is 'document.getEl ementById[..] is null or is not an object'

    Any ideas
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    hi ...

    please post a link to a testpage or some code that is related to the problem ... so that we may have a closer look at it. how do you create tabs, panels, etc. ... we need more information to be able to help ...

    kind regards

    Comment

    • GunnarJ
      New Member
      • Mar 2007
      • 7

      #3
      Here is some code:

      Code:
      <head runat="server">
          <title>Untitled Page</title>
           <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
           <script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"></script>
            <script type="text/javascript">
               var map = null; 
               
               function GetMap()
               {
                 var xpos = 59.33490764970564;
                 var ypos = 18.101434707641615;
                 var title = 'Radiohuset';
                 var note = 'Gärdets pärla';
                 var zoom =  10;
                 var typ =  'r';// r=road h=hybrid a=aerial(satellite)
                 var lock = false
                         
                  map = new VEMap('myMap');  
                   map.LoadMap(new VELatLong(xpos, ypos), zoom ,typ , lock);//--Kordinater,zoomlevel 19=närmast,karttyp,låst karta
                   //map.AttachEvent("onclick", onMapClick);
                   map.AttachEvent("onclick", MouseHandler);
                   map.AttachEvent("ondoubleclick", MouseHandler);
                   map.AttachEvent("onmousedown",MouseHandler);
                   map.AttachEvent("onmouseup",MouseHandler);
                   map.AttachEvent("onmousewheel",MouseHandler);
                   //map.AttachEvent("onmouseover",MouseHandler);
      
      //Markera inte Radiohusets koordinater med nål utan centrera bara på den
                 //var pushpin = new VEPushpin('1',new VELatLong(xpos, ypos), null, title, note  ); //Id - must be unique  //latitude, longitude //icon url  //Title  //Notes
                   //map.AddPushpin(pushpin);
                   map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
                   map.ShowMiniMap(); // map.ShowMiniMap(100,200,VEMiniMap.Small);
                   map.ShowDisambiguationDialog(false);//-- visar inte stddialogen vid fler sökträffar
        
        } 
        
          function MouseHandler(e)
      {
         if (e.eventName == "onclick")
        {
          if (e.leftMouseButton)
          {
      //    var x = e.mapX;
      //    var y = e.mapY;
      //    pixel = new VEPixel(x, y);
      //    var LL = map.PixelToLatLong(pixel);
      //    map.SetCenter(LL);
      //    return false;
           }
           
          else if (e.rightMouseButton)
           {
               var x = e.mapX;
               var y = e.mapY;
               pixel = new VEPixel(x, y);
               var LL = map.PixelToLatLong(pixel);
                 document.getElementById('Text1').value=LL;
            }
          else
          {
          alert('mclick');
           }
      }
        else if (e.eventName == "ondoubleclick")
        {
          if (e.leftMouseButton)
          {
           }
          else if (e.rightMouseButton)
           {
           }
          else
           {
           }
        }
       else if (e.eventName == "onmouseover") 
       {
       // check to see if we have hovered over a pushpin
      //   if(e.elementID=null)
      //   {
      //     var location = map.GetShapeByID(x.elementID).GetPoints()[0];
      //    alert('you hovered over latitude :' + location.Latitude 
      //       + ' longitude :' + location.Longitude);  
      //     }
      
      // alert("cc");
       }
      }
       
            </script>
      </head>
      
      <body style="background-color: #ffffcc" onload="GetMap();">
           <form id="form1" runat="server">
              <asp:ScriptManager ID="ScriptManager1" runat="server" />
                        
                  <cc1:TabContainer ID="TabContainer1" runat="server" Height="400px" Width="791px" >
                      <cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="Ärende" ToolTip="Här startar du ett nytt ärende">
                     <ContentTemplate>
                     <asp:TextBox ID="Text1" runat="server"></asp:TextBox>
                                   
                     
                     </ContentTemplate>
                      </cc1:TabPanel>
                      <cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="Ärende-uppdatering" ToolTip="Här väljer du ett befintligt ärende att uppdatera">
                      <ContentTemplate>
                                       </ContentTemplate>
                      </cc1:TabPanel>
                      <%--http://www.thescripts.com/forum/thread650780.html--%>
                      <cc1:TabPanel ID="TabPanel3" runat="server" HeaderText="Karta" ToolTip="Här kan du positionera ditt ärende">
                      <ContentTemplate>
                        
                        <div   id='myMap'  align="left" style="position:relative; height:100% ;width:100%"></div> 
      
                        
                       
                     
                          </ContentTemplate>
                      </cc1:TabPanel>
                  <cc1:TabPanel ID="TabPanel4" runat="server" HeaderText="Admin" ToolTip="Administrattionsgöromål du är behörig till">
                      <ContentTemplate>
                      </ContentTemplate>
                      </cc1:TabPanel>
                  </cc1:TabContainer>
               <asp:TextBox ID="Text2" runat="server"></asp:TextBox>
              
          </form>
      </body>
      When loading I get Javascript error 'exception thrown but not caught'
      The map is however loaded but only parially visible. When I doubleclick it it expands to fill the TabPanel.
      When I rightclick the map the Javascript error says 'document.getEl ementById('..') is null or not an object'

      (If I change Text1 to the textbox Text2 it works OK)

      Hope this makes the problem clearer.

      Gunnar

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5388

        #4
        hmmm ... may be the id of the textbox ('Text1') is replaced with something else when the page is loaded into the browser? have a look at the source-code when the page is loaded in IE ... and try to find the textbox ... and find out its id.

        Comment

        Working...