Dynamic generated TextBox

  • Thread starter Thread starter Chen Sun via .NET 247
  • Start date Start date
C

Chen Sun via .NET 247

I have posted this message 15 hours ago but I still could not seeit. So I decide repost it.

I have successully used Jeffrey Ton's method to generate dymanicTextBox. Now my problem is that After the textbox show firsttime, I changed the text of textbox. I WANT to use thes new textin the textbox. But since the textbox showed second time is newgenerated, or say new populated.

So how could I use the new Text in textBox?

Thanks.

Chen
 
Hi,

1) You need to recreate your dynamic control each time page recreate
(even in postback).

2) If you want to use dynamic control value from page load event you
need to create dynamic control in page OnInit.

override protected void OnInit(EventArgs e)
{
TextBox oTxt = new TextBox();
oTxt.Visible = true;
oTxt.ID = "oNat";
this.FindControl("Form1").Controls.Add(oTxt);
.....

private void Page_Load(object sender, System.EventArgs e)
{
string s = ((TextBox)this.FindControl("oNat")).Text;
}

HTH
Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)52-8888377


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top