I'm tring to move html element on run time.
(1) Call function from code behind. (Button1_Click1 event)

ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "myfunction", "testFunc(100,200);", true);

(2) It redirect to JS function. (This function is used to change the location of html attribute)

function testFunc(x,y) {

    document.getElementById('draggable').style.top = x;
    document.getElementById('draggable').style.left  = y;

}

in number 2, if add alert, it's working properly. (It means function is executing successfully)

But html div is not changing. What could be the problem?

This is my HTML code.

 <div>
        <b>This is test page<br />
        </b>
        <div id="draggable" class="ui-icon-image">
           <img id="img1" src="/Resource/location_icon.png" width="27px" height="45px" />
        </div>
     <asp:Button ID="Button1" runat="server"  Text="Button" onclick="Button1_Click1" />
 </div>

Try

document.getElementById('draggable').style.left  = y + "px";

But have in mid that if your element is not absolut positioned, top and left will only act like margins.

Also, if you javascript is working, test only the styles and see if it changes, test step by step, like:

<div id="draggable" class="ui-icon-image" style="top: 200px; left: 100px">
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.