locked
how to position controls on aspx pages? RRS feed

  • Question

  • i thought that programmatically positioning a control on an aspx page at runtime would be the most trivial task in the world but clearly it is not.....the problem started with wanting to edit a treeview node in place. well this is impossible so i thought i would simulate functionality by positioning a textbox over the selected node dynamically....

    well excuuuuuse me.....i can't locate the node's position or move the textbox position on a super simple aspx page....
    no control property contains the location of the control.....

    is there a way to dynamically set control location / position during runtime? vs2008, vista, asp.net. the control is configured as absolute positioning.
    • Moved by nobugz Sunday, July 5, 2009 9:01 PM forums.asp.net (From:.NET Base Class Library)
    Sunday, July 5, 2009 8:11 PM

Answers

  • Hi tony,

    You would get a better response if you post to the asp.NET forums at www.asp.net/forums.

    The reason that you are facing this issue is because starting VS2005 , the default layout on web pages was of flow layout and not grid layout like VS 2003.

    The best way to position your controls would be through div tags and CSS.  Use <br /> tags for line breaks and &nbsp; for non breaking spaces to move your text boxes. CSS properties like margin,display,position are also quite helpful.

    Ganesh Ranganathan
    [Please mark the post as answer if it answers your question]
    Sunday, July 5, 2009 8:23 PM
  • when you use:

    TextBox1.Style["Border"] = "solid 1px black";

    It gets rendered to HTML as

     <input name="TextBox1" type="text" id="TextBox1" style="Border:solid 1px black;" /> 

    That is an inline style which you just used which can be done with CSS much more effectively. CSS seperates your styling from your markup making your page easier to maintain. 

    Ganesh Ranganathan
    [Please mark the post as answer if it answers your question]
    Sunday, July 5, 2009 10:38 PM
  • Here's the forum where can ask ASP.NET questions with the link: http://asp.net/forums

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Twitter, Wiki)

    Friday, December 7, 2012 9:56 PM

All replies

  • Hi tony,

    You would get a better response if you post to the asp.NET forums at www.asp.net/forums.

    The reason that you are facing this issue is because starting VS2005 , the default layout on web pages was of flow layout and not grid layout like VS 2003.

    The best way to position your controls would be through div tags and CSS.  Use <br /> tags for line breaks and &nbsp; for non breaking spaces to move your text boxes. CSS properties like margin,display,position are also quite helpful.

    Ganesh Ranganathan
    [Please mark the post as answer if it answers your question]
    Sunday, July 5, 2009 8:23 PM
  • you answered a totally different question.

    the correct answer is

    EditBox.Style[

    "top"] = "some numeric value";

    Sunday, July 5, 2009 10:20 PM
  • when you use:

    TextBox1.Style["Border"] = "solid 1px black";

    It gets rendered to HTML as

     <input name="TextBox1" type="text" id="TextBox1" style="Border:solid 1px black;" /> 

    That is an inline style which you just used which can be done with CSS much more effectively. CSS seperates your styling from your markup making your page easier to maintain. 

    Ganesh Ranganathan
    [Please mark the post as answer if it answers your question]
    Sunday, July 5, 2009 10:38 PM
  • Here's the forum where can ask ASP.NET questions with the link: http://asp.net/forums

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Twitter, Wiki)

    Friday, December 7, 2012 9:56 PM