Add Text Box From Code behind in HTML

Add Text Box From Code behind in HTML 

 
This code-sample includes adding TextBox from code behind. This sample can be used for many purposes. For example, you can create an application of an online exam and an update record based on a question will have better feelings about your application.
 
Here is the code
  1. <body>  
  2.     <form id="form1" runat="server">  
  3.         <asp:PlaceHolder ID="placeHolder" runat="server" />  
  4.         <div></div>  
  5.     </form>  
  6. </body>     
Write C# code in the Page_Load event. 
  1. protected void Page_Load(object sender, EventArgs e)    
  2.         {    
  3.             if (!IsPostBack)    
  4.             {    
  5.                 HtmlInputText input;    
  6.                 HtmlTable tbl = new HtmlTable();    
  7.                 HtmlTableRow row;    
  8.                 HtmlTableCell cell;    
  9.                 string HtmlContent = "  
  10. <table>";    
  11.                 for (int i = 0; i < 4; i++)    
  12.                 {    
  13.                     //Here we have to update record based  for question    
  14.                     //we can store id in name parameter for choice so we can further update choice for questions    
  15.                     HtmlContent += "  
  16.     <tr>  
  17.         <td>" + i + "</td>" + "  
  18.         <td>  
  19.             <input type='text' class='testoption' name='1' value='optionvalue" + i + "'/>  
  20.         </td>  
  21.     </td>";    
  22.                 }    
  23.                 HtmlContent += "  
  24. </table>";    
  25.                 placeHolder.Controls.Add(new Literal() { ID = "literal", Text = HtmlContent });    
  26.             }    
  27.         }     
Build the application and you can debug it.