This code-sample includes add TextBox from code behind. This sample can be used for many puroses. For example, you can create an application of online exam and update record based for question will have better feelings about your application.
Here is the code
- <body>
- <form id="form1" runat="server">
- <asp:PlaceHolder ID="placeHolder" runat="server" />
- <div>
- </div>
- </form>
- </body>
Wirte C# code in the Page_Load event.
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- HtmlInputText input;
- HtmlTable tbl = new HtmlTable();
- HtmlTableRow row;
- HtmlTableCell cell;
- string HtmlContent = "<table>";
- for (int i = 0; i < 4; i++)
- {
-
-
- HtmlContent += "<tr><td>" + i + "</td>" + "<td><input type='text' class='testoption' name='1' value='optionvalue" + i + "'/></td></td>";
- }
- HtmlContent += "</table>";
- placeHolder.Controls.Add(new Literal() { ID = "literal", Text = HtmlContent });
- }
- }
Build the application and you can debug it.