How to position a textbox under an image in, c# 2.0, C# 2008.  I have a page that contains a few images (which hold Google chart url's).
Under one of the images I wish to position a mult-iline text box that lines up directly under that image (AFTER the images and charts have been created and displayed...I will not know the exact position to put the textbox until then). Please show me the  syntax (style, etc), for the textbox, and then show me how to get the position of the image so that I can use that position to line up the textbox (in the c# code).  Thanks
Who is Participating?
EspavoConnect With a Mentor Commented:
Is the size of the TextBox fixed?
A simple <br /> between the Image and the TextBox will position the textbox directly below the image...
use this javascript code. you can call it during the onload of the page and pass the image.clientID from code behind.

            <script language='javascript'>
                  function addTextBox(imgElementId)
                        var imgElement = document.getElementById(imgElementId);
                        var txtBox = document.createElement('input');
                        var breakElement = document.createElement('br');
               = 'txtData';
                        txtBox.type = 'text';
                        txtBox.value = 'Hello World';
                        imgElement.parentElement.insertBefore(txtBox, imgElement.nextSibling);
                        imgElement.parentElement.insertBefore(breakElement, imgElement.nextSibling);
eelouAuthor Commented:
What I did was to move the image that I wanted the textbox under, to the first position.  Thus the textbox lined up under it.
The thing to watch-for doing it like this is that if the image is below a certain size that the textbox will position itself next to the image... (The <br /> will prevent that from happening...)
All Courses

From novice to tech pro — start learning today.