Here, you will see how to create a TextBox upon each button click using JavaScript and CSS.
I hope this code is very helpful for creating a paper format for an online examination project. Check it out. If you have any concerns then let me know.
.Aspx Code
.CS Code
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.Script.Serialization;
- using System.Data;
- using System.Text;
- public partial class _Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void btnSave_Click(object sender, EventArgs e)
- {
- string[] SName = Request.Form.GetValues("SName");
- string[] Email = Request.Form.GetValues("Email");
- string[] Address = Request.Form.GetValues("Address");
- DataTable dtable = dt();
- for (int i = 0; i <= SName.Length - 1; i++)
- {
- DataRow row1 = dtable.NewRow();
- row1["SName"] = SName[i];
- row1["Email"] = Email[i];
- row1["Address"] = Address[i];
- dtable.Rows.Add(row1);
- }
- GetData(dtable);
- }
- static DataTable dt()
- {
- DataTable dt = new DataTable();
- dt.Columns.Add("SName");
- dt.Columns.Add("Email");
- dt.Columns.Add("Address");
- return dt;
- }
- protected void GetData(DataTable dt)
- {
- StringBuilder sb = new StringBuilder();
- if (dt.Rows.Count > 0)
- {
- sb.AppendLine("<table cellpadding=\"0\" cellspacing=\"0\" class=\"custom-tablePopup\">");
- sb.AppendLine("<tr><th>Student Name<th>");
- sb.AppendLine("<th>Email</th>");
- sb.AppendLine("<th>Address</th></tr>");
- foreach (DataRow dr in dt.Rows)
- {
- sb.AppendLine("<tr>");
- sb.AppendLine("<td>" + dr["SName"].ToString() + "</td>");
- sb.AppendLine("<td>" + dr["Email"].ToString() + "</td>");
- sb.AppendLine("<td>" + dr["Address"].ToString() + "</td>");
- sb.AppendLine("</tr>");
- }
- sb.AppendLine("</table>");
- lit.Text = sb.ToString();
- }
- }
- }