0

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?

1
  • can you show what you've tried ? or some code at least? its hard to help like this! Commented Jul 9, 2012 at 6:54

3 Answers 3

1

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);
 }
Sign up to request clarification or add additional context in comments.

3 Comments

Not sure how that would work since all the work is done in a Timer_Tick method.
u means controls are created on a tymer tick event ?
Yes because the amount of controls created is based on some calculation and the timer is there for the updateProgress to work
0

You have to use Page_Init/Load event handler to create controls runtime (dynamically).

Comments

0

For that you can use the ViewState

string data = ViewState["myData"];

ViewState["myData"] = data;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.