add html controls to aspx form at run time , use them like server controls

Hi ,

I have to  add html to my aspx form at run time and use added  controls as server cotrols ..
let says
 I need to create one form in which html comes from db . and then control in that behave like server control .
  first table that contains html for form  .

 <table><tr><td>First name</td><td><input type="text" name="fist_name" size="40" ></td></tr>
        <tr><td>Last name</td><td><input type="text" name="last_name" size="20" ></td></tr>
</table > 

and  second table that contains two field fist_name and last_name .  
when i run that from it show two text box (above html of first table  ) and
on button click value of textboxex to be save in second table  .
please help .
thanks  in advance
Who is Participating?
That's quite a story. I'm not planning to do your work for you, I hope you settle with a few pointers Sounds to me that you would be better of using GridView or Repeater or related controls for your data from your database. But if you want to create them by hand, you can do that like this (see the comments for the explanations, paste the code in the page_load):

' create html table '
Dim htmlTable As New HtmlTable()
Dim htmlTableRow As New HtmlTableRow()
' first name cell and ' 
Dim htmlTableCell As New HtmlTableCell
htmlTableCell.InnerHtml = "First name"
' add cell to row ' 
' input field ctrl '
Dim htmlInput As New HtmlInputText
htmlInput.Name = "first_name"
htmlInput.Size = 40
' input field cell and adding the ctrl to the cell '
htmlTableCell = New HtmlTableCell
' add cell to row '
' add rows to the table '
' add table to the page ' 

Open in new window

To work with dynamic controls and to create them is a lot of work. All you said in your post can also be done by just typing that structure in the  ASPX page and giving the relevant elements an runat="server" to make them server controls. The button should be an asp:Button and the textboxes should be asp:TextBox to make it easier to reference them.
eteranAuthor Commented:
hi abel  thanks for reply
   i have  add lots of html and we can't break it  .
  So we can't use your first way we are already using that .
  we have to add html as it is ...
@TheLearnedOne: it might be that you misinterpreted the last comment of "eteran", here's my reading of the same:

>> "so we can't use your first way". My "first way" was the suggestion to use a gridview.
>> "we have to add html as it is". That was what I showed as an example. The asker here confirms that he's going for my approach, which is shown in the comment of http:#24190323

And then forgot to grade... ;-)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.