Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 7th, 2007, 03:40 AM
Registered User
 
Join Date: May 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default dynamic textboxs

in page load dynamically cretaed textboxs with below code its working well, but im unable to retrieve textbox text using button event plz help me out on the same issue
for i = 1 to 5

            dim txtBox as new TextBox
            txtBox.ID = String.Format("txtBox{0}", i)
            Panel1.Controls.Add(txtBox)
         next
 
Old May 8th, 2007, 02:52 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

You can use the line below to retrieve value of textbox:

Response.Write(((TextBox)Panel1.Controls[2]).Text);



Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
 
Old May 8th, 2007, 06:28 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

you can also do something like:

foreach(Control ctrl in Panel1.Controls)
{
   if(ctrl is TextBox)
   {
     TextBox txt = (TextBox)ctrl;
     Response.Write(txt.Text);
   }
   else
   {
      //do something
   }
}

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old May 8th, 2007, 07:26 AM
Registered User
 
Join Date: May 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Mike
whe i place the below code in button event
i got an msg that textbox is a type cannot be used as expression
Response.Write(((TextBox)Panel1.Controls[2]).Text);

so please help me
 
Old May 8th, 2007, 07:28 AM
Registered User
 
Join Date: May 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default


where i have to keep the below code

Quote:
quote:Originally posted by dparsons
 you can also do something like:

foreach(Control ctrl in Panel1.Controls)
{
if(ctrl is TextBox)
{
     TextBox txt = (TextBox)ctrl;
     Response.Write(txt.Text);
}
else
{
     //do something
}
}

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old May 8th, 2007, 07:40 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Your click event i suppose.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Columns & Dynamic Grouping ??? nileshgambhava BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 1 March 24th, 2008 07:58 AM
help writing dynamic form data to dynamic table ublend SQL Server ASP 1 June 1st, 2007 08:09 AM
help writing dynamic form data to dynamic table ublend Classic ASP Professional 1 June 1st, 2007 08:08 AM
dynamic textboxs hirish.reddy General .NET 3 May 8th, 2007 07:03 AM
How to check data entered 3 textboxs minhpx General .NET 1 September 13th, 2004 11:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.