How can you move ASP.Net controls to different places on the Web form at runtime?

前端 未结 5 1856
迷失自我
迷失自我 2021-01-01 01:41

Is there an accepted way to \"move\" a control.

My client wants to place a certain chunk of markup (representing some visual element) in one of several different pla

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-01 02:33

    An alternative (and one I've seen done many times before) is through javascript and the DOM. Render your control inside a hidden div tag. So you would render your content here:

    
    

    Then, lets say you wanted to move it all here (the span tag is inside because that's what we're going to replace):

    You would define the following javascript:

    
    

    And when you want to move the content to the new location, call:

    
    

提交回复
热议问题