I have a dynamic table with some textboxes (also dynamic) and some buttons which do postback onclick. How can I make the page remember what text was entered in the boxes after postback, after clicking a button?
3 Answers
You have to create controls in a tymer click event.For that Create a new user control. Add public Properties in it for adding how much controls u have to add. And in Web user control Page INit and Page_load event Add the required number of controls. Hope this will work.
//IN web user control aspx page add a place holder in which u add your dynamic controls
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
<asp:PlaceHolder runat="server" ID="mycontrol"/>
// WEb User Control Code Behind
// Create public properties
public int totalnoOfcontrols
{
get;
set;
}
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
// save values here
}
}
protected void Page_Init(object sender, EventArgs e)
{
// create dynamic controls here
TextBox t = new TextBox();
t.Text = "";
t.ID = "myTxt";
mycontrol.Controls.Add(t);
}
3 Comments
user1468537
Not sure how that would work since all the work is done in a Timer_Tick method.
Waqar Janjua
u means controls are created on a tymer tick event ?
user1468537
Yes because the amount of controls created is based on some calculation and the timer is there for the updateProgress to work