473,715 Members | 5,945 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

get content of text boxes dynamically created

Hi all,

I create a set of text-boxes based on user input:

for (int i = 0; i < Convert.ToInt16 (keywordsDropDo wnList.Text);
i++)
{
myTextBox = new TextBox();
myTextBox.Colum ns = 5;
myTextBox.ID = "parameterTextB ox"+Convert.ToI nt16(i);
myTextBox.TabIn dex = (short) (i+1);
buttonPlaceHold er.Controls.Add (myTextBox);
}

The text boxes are followed by a button that, when clicked, should get
the content form the text boxes and put em in a database. How can I get
the content from teh text boxes?

I cannot use
someVar = parameterTextBo x0.text
since it is not known

Thanks in advance
Stijn

Aug 31 '06 #1
5 1609
Stijn,

buttonPlaceHold er.FindControl ("parameterText Box1") as TextBox

should do.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
<ta******@gmail .comwrote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
Hi all,

I create a set of text-boxes based on user input:

for (int i = 0; i < Convert.ToInt16 (keywordsDropDo wnList.Text);
i++)
{
myTextBox = new TextBox();
myTextBox.Colum ns = 5;
myTextBox.ID = "parameterTextB ox"+Convert.ToI nt16(i);
myTextBox.TabIn dex = (short) (i+1);
buttonPlaceHold er.Controls.Add (myTextBox);
}

The text boxes are followed by a button that, when clicked, should get
the content form the text boxes and put em in a database. How can I get
the content from teh text boxes?

I cannot use
someVar = parameterTextBo x0.text
since it is not known

Thanks in advance
Stijn

Aug 31 '06 #2
But you can use Page.FindContro l

TextBox tb = (TextBox)Page.F indControl("par ameterTextBox0" );
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

<ta******@gmail .comwrote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
Hi all,

I create a set of text-boxes based on user input:

for (int i = 0; i < Convert.ToInt16 (keywordsDropDo wnList.Text);
i++)
{
myTextBox = new TextBox();
myTextBox.Colum ns = 5;
myTextBox.ID = "parameterTextB ox"+Convert.ToI nt16(i);
myTextBox.TabIn dex = (short) (i+1);
buttonPlaceHold er.Controls.Add (myTextBox);
}

The text boxes are followed by a button that, when clicked, should get
the content form the text boxes and put em in a database. How can I get
the content from teh text boxes?

I cannot use
someVar = parameterTextBo x0.text
since it is not known

Thanks in advance
Stijn

Aug 31 '06 #3
Thanks for the reply. i haven't made it work yet though. It seems that
FindControl can't find the textbox since null is returned. The
textboxes are placed inside a view (and multiview) and then inside a
placeholder (suing a masterpage). Maybe this is the reason why null is
returned?

Regards,
Stijn

Teemu Keiski schreef:
But you can use Page.FindContro l

TextBox tb = (TextBox)Page.F indControl("par ameterTextBox0" );
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

<ta******@gmail .comwrote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
Hi all,

I create a set of text-boxes based on user input:

for (int i = 0; i < Convert.ToInt16 (keywordsDropDo wnList.Text);
i++)
{
myTextBox = new TextBox();
myTextBox.Colum ns = 5;
myTextBox.ID = "parameterTextB ox"+Convert.ToI nt16(i);
myTextBox.TabIn dex = (short) (i+1);
buttonPlaceHold er.Controls.Add (myTextBox);
}

The text boxes are followed by a button that, when clicked, should get
the content form the text boxes and put em in a database. How can I get
the content from teh text boxes?

I cannot use
someVar = parameterTextBo x0.text
since it is not known

Thanks in advance
Stijn
Sep 1 '06 #4
Hi all,

I tried the findcontrol with textbox I added via the editor but that
also returned a null. I used Page.findcontro l(id) and just
findcontrol(id) .

Someone has an idea what I'm doing wrong?

Regards
Stijn
ta******@gmail. com schreef:
Thanks for the reply. i haven't made it work yet though. It seems that
FindControl can't find the textbox since null is returned. The
textboxes are placed inside a view (and multiview) and then inside a
placeholder (suing a masterpage). Maybe this is the reason why null is
returned?

Regards,
Stijn

Teemu Keiski schreef:
But you can use Page.FindContro l

TextBox tb = (TextBox)Page.F indControl("par ameterTextBox0" );
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

<ta******@gmail .comwrote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
Hi all,
>
I create a set of text-boxes based on user input:
>
for (int i = 0; i < Convert.ToInt16 (keywordsDropDo wnList.Text);
i++)
{
myTextBox = new TextBox();
myTextBox.Colum ns = 5;
myTextBox.ID = "parameterTextB ox"+Convert.ToI nt16(i);
myTextBox.TabIn dex = (short) (i+1);
buttonPlaceHold er.Controls.Add (myTextBox);
}
>
The text boxes are followed by a button that, when clicked, should get
the content form the text boxes and put em in a database. How can I get
the content from teh text boxes?
>
I cannot use
someVar = parameterTextBo x0.text
since it is not known
>
Thanks in advance
Stijn
>
Sep 1 '06 #5
You need to call FindControl on the control that directly contains the
control you are trying to find. Did you try my suggestion

buttonPlaceHold er.FindControl ("parameterText Box1") as TextBox ?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
<ta******@gmail .comwrote in message
news:11******** **************@ 74g2000cwt.goog legroups.com...
Hi all,

I tried the findcontrol with textbox I added via the editor but that
also returned a null. I used Page.findcontro l(id) and just
findcontrol(id) .

Someone has an idea what I'm doing wrong?

Regards
Stijn
ta******@gmail. com schreef:
>Thanks for the reply. i haven't made it work yet though. It seems that
FindControl can't find the textbox since null is returned. The
textboxes are placed inside a view (and multiview) and then inside a
placeholder (suing a masterpage). Maybe this is the reason why null is
returned?

Regards,
Stijn

Teemu Keiski schreef:
But you can use Page.FindContro l

TextBox tb = (TextBox)Page.F indControl("par ameterTextBox0" );
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

<ta******@gmail .comwrote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
Hi all,

I create a set of text-boxes based on user input:

for (int i = 0; i < Convert.ToInt16 (keywordsDropDo wnList.Text);
i++)
{
myTextBox = new TextBox();
myTextBox.Colum ns = 5;
myTextBox.ID = "parameterTextB ox"+Convert.ToI nt16(i);
myTextBox.TabIn dex = (short) (i+1);
buttonPlaceHold er.Controls.Add (myTextBox);
}

The text boxes are followed by a button that, when clicked, should
get
the content form the text boxes and put em in a database. How can I
get
the content from teh text boxes?

I cannot use
someVar = parameterTextBo x0.text
since it is not known

Thanks in advance
Stijn

Sep 3 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1993
by: Dale | last post by:
I am trying to figure out how to have a script dynamically create and then dispose of a text file. A script will generate a text file using the standard I/O functions and then present a link so the user can right-click and download. That part is easy. The file could be created in a unique directory on the server for each user such that different users don't clobber each other. How can I make sure the file is later removed if the user...
11
7236
by: Robert Bowen | last post by:
Hello all. I have been given mock-ups (in static HTML) of some pages for a site I am working on. The client would like these pages to look exactly as they do now. The problem is that the content is dynamic, it comes from a database. My question -- with CSS (because with HTML tables I don't think it's possible) how can I make my text "flow" in two columns? eg. If there are 100 lines of content, I would like 50 to be in the 1st column, and...
1
4325
by: sekisho | last post by:
I'm dynamically adding a column of labels and a column of text boxes to a panel on a webform, based on data returned from an SQL query, which the user builds by selecting options from a few dropdowns and hitting the 'Search' button. The first column returned is a user name and is added to the panel as a label, the second is a number and is added to the label as the text property of a textbox, so the user can update it. When the...
3
1465
by: simon | last post by:
Hello, i'm looking to create an aspx page that is basically a FAQ page i'm not sure if this can be done, but would love some help with suggestions of how to do it another way if this is not possible on the aspx page i have a table with 1 row and 2 columns in it, in the column on the left i have an asp:label, lblLinks and in the column on the right i have another asp:label, lblBody i'm reading the content of the links and body from...
2
2137
by: Sethos | last post by:
I am sure that this has been covered, hashed, and rehashed, but a search on the group did not produce the answer, so forgive me if this seems like a "newbie" type question... Besically, I have a form on which the users can click on a button to add text boxes dynamically. That all works without a hitch. The problem comes in trying to verify the information in the boxes. Below is a very abbreviated example of the code I have in the form:
0
1665
by: nick78 | last post by:
hi, i want to create a web form where someone can do some input or pick strings from select boxes. after that the person can click a preview button and a website will be generated dynamically. so i thought i should use typo3. first of all i created a html-template. then a page tree with all the sites that could possibly appear. in the end only the sites with content, will be shown. all of this must happen automatically. so i need a php...
1
4909
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have set text boxes and labels inside the table rows. I then added a button. All of these are done through code. The problem that i am having is i can get the value from a text box with resides inside the first panel (out side of panel that is...
1
1803
by: adarshyam | last post by:
can anybody tel me how to clear values from dynamically created text boxes?? using a clear button.. this is the code used to create dynamic text boxes.. if i press clear button then it must clear all the values entered in al the textboxes Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If IsPostBack Then Try If Not TextBox1.Text Is String.Empty Then ...
5
7784
by: ofilha | last post by:
I have created a report in design mode. However, some of the fields i need are dynamic. That is, i have a series of fields text boxes mostly that must show up only as needed. I also have some labels that also should dynamic depending on the text boxes. I first tried createReportcontrol during the OnOpen event for the report,and when i tried to run it, it would give me an error 2147, that i must be in design view in order to create or delete...
0
8821
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9340
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9196
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9047
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6646
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5967
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2118
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.