Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

What is the best way to add textboxes to a drawing in asp.net

I am developing an application that takes power readings from a database and displays them. What I want is to super impose the readings on to a mimic drawing.
see attached example, Power mimic example,  the readings are the power readings. I thought of creating a table and inserting pictures and textboxes in to cells to make up the page, this is alot of work. If any develpers can help with a better solution here are some points.
  • 2
1 Solution
If I understand what you are trying to do correctly the first idea that comes to my mind is to lay the image as a background and use CSS to position your textboxes as you'd like. It's a little work, certainly less work than tables (tables are for tabular data not layout...just had to say that).

So I'd do something like this(just to get you started):
<see code><see screen shot> Power Textbox overlay SS
    <form id="form1" runat="server">
    <div style="background-image:url('img/Power-Asp.jpg'); height:298px; width:534px; position:relative;">
	<asp:TextBox ID="TxtPwr1" runat="server" style="position:absolute; top:62px; left: 84px; width:58px; " />

Open in new window

dearnessAuthor Commented:
Thanks for the pronpt reply, exactly what I want. I am obviously new to this. Now to get brush up on CSS. Thanks.
The only trick to this is the position relative/absolute.

1. There is an outer container, in this case a <div>. This container has the background-image and its dimensions are set to the same height/width as that image. This container has position relative. What this means is that any absolutely positioned elements inside of it will calculate their left/right/top/bottom position from this parent rather than the entire <html> element.

2. You make textboxes inside the <div>, set them absolute, set their left/top dimensions and adjust till you get where you want. In general this is what is happening. I also set the size of the textbox but I'm hoping it will be pretty simple for you to follow.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now