Dynamically move control.

Discussion in 'ASP .Net Web Controls' started by Shawn, Apr 5, 2006.

  1. Shawn

    Shawn Guest

    I am trying to find a way to move a button control to a location where the
    mouse is clicked. I got all the code in to find the coordinates and populate
    a hidden control with the values, but when I try to move the button on
    postback, it moves, but to a specific place on the form everytime. Here is
    where I am doing the move...

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
    Handles Me.Init
    btnLoc.Style("Position") = "Absolute"

    btnLoc.Style("Top") = "25px"

    btnLoc.Style("Left") = "100px"

    End Sub

    Any ideas???
     
    Shawn, Apr 5, 2006
    #1
    1. Advertising

  2. Shawn

    Axel Dahmen Guest

    Hi Shawn,

    are you sure you want to do this on postback? This way the user would need
    for the page to be reloaded before the button appears at the new position.
    Depending on the user's internet connection this might take a while...

    Anyway, if you want to set a server web control's properties on postback,
    you must do so in Page_Load(), not Page_Init(), because object properties
    are all reset to their initial values *after* Page_Init() if the object's
    EnabledViewState property is set to true.

    HTH,
    Axel Dahmen


    ----------------
    "Shawn" <> schrieb im Newsbeitrag
    news:#...
    > I am trying to find a way to move a button control to a location where the
    > mouse is clicked. I got all the code in to find the coordinates and

    populate
    > a hidden control with the values, but when I try to move the button on
    > postback, it moves, but to a specific place on the form everytime. Here is
    > where I am doing the move...
    >
    > Protected Sub Page_Init(ByVal sender As Object, ByVal e As

    System.EventArgs)
    > Handles Me.Init
    > btnLoc.Style("Position") = "Absolute"
    >
    > btnLoc.Style("Top") = "25px"
    >
    > btnLoc.Style("Left") = "100px"
    >
    > End Sub
    >
    > Any ideas???
    >
    >
     
    Axel Dahmen, Apr 6, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. eddie wang
    Replies:
    1
    Views:
    422
    Peter O'Reilly
    Jul 23, 2003
  2. =?Utf-8?B?UmV6YSBOYWJp?=

    Load User Control Dynamically, Cast object dynamically

    =?Utf-8?B?UmV6YSBOYWJp?=, Mar 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    6,831
    Matt Berther
    Mar 5, 2005
  3. Eduardo78
    Replies:
    0
    Views:
    279
    Eduardo78
    Nov 3, 2005
  4. Andrew Tomazos
    Replies:
    2
    Views:
    703
    Nobody
    Dec 12, 2011
  5. fidodido

    Dynamically move elements into form ?

    fidodido, Dec 6, 2005, in forum: Javascript
    Replies:
    6
    Views:
    156
Loading...

Share This Page