Dynamically adding DOM elements using asp.net ajax

Last post 01-07-2009 1:37 AM by Pawan_Mishra. 0 replies.

Sort Posts:

  • Dynamically adding DOM elements using asp.net ajax

    01-07-2009, 1:37 AM
    • Star
      8,769 point Star
    • Pawan_Mishra
    • Member since 03-13-2008, 7:37 AM
    • Bangalore
    • Posts 1,281

    Hi ,

    I am using asp.net ajax client side function like getLocation() , getBounds() and setLocation() . If I use these function on elements which are defined in the markup of page they al work fine . But if any element is created during run time in javascript they are not working . Following is a sample on which I am struggling for some time :-

    var tdUser = $get('<% = tdUser.ClientID %>');    --> TD element defined in markup
    var tdlocation = Sys.UI.DomElement.getLocation(tdUser); 
        var tdBounds = Sys.UI.DomElement.getBounds(tdUser);
       
        var tdDiv = document.createElement("div");
        var strTable = "<table><tr><td>Create User</td></tr><tr><td>Manage User</td></tr></table>";
        tdDiv.innerHTML = strTable;   -----------> Till here things are fine 
       
        Sys.UI.DomElement.setLocation(tdDiv , tdlocation.x , tdlocation.y-tdBounds.height); --> I want to append this new element tdDiv just below tdUser

    Any words on this will be of great help to me . If some can provide me a sample code of how to use these functiosn with dynamically added elements then it will be too good .

    Regards
    Pawan Mishra

    Moving from Asp.Net to WPF and SilverLight .....

    .Net 360°
Page 1 of 1 (1 items)