tags:

views:

30

answers:

2

Hi all,

How do I add a label next to a textbox during runtime in asp.net? Unlike window form, I can't set the location of the control. So how do I instantiate a label and set the location next to a declared textbox?

Or may be adding a string like "<span>my message</span>" next to the textbox will work for me as well.

Thank you.

+2  A: 

The easiest thing to do is to put a regular label control on the webform at the desired location and manage its visibility in the code behind.

JasonS
That's the worse case I will do because I have a big list of textbox.
Dreteh
I would have done the same too. But here the case is that there are too many controls.
ckv
+2  A: 

Take a look at this MSDN page: Adding Controls to a Web Forms Page Programmatically

Using the AddAt method will allow you to position the control within the control tree structure of the page.

You have a lot of control over how you can add controls dynamically to a page.

Alison