473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

access dynamic textbox

How to access the value of the dynamic textbox by its id?
I created more dynamic textbox using the below in loop
Dim tb As New TextBox
tb.ID = "txt_" + Str$(i)
and it assigned unique id.
then how to access each textbox value by its id without using javascript.
Jan 27 '09 #1
4 2267
naga01
3
Try this
Expand|Select|Wrap|Line Numbers
  1. for(i=0; i<= 10; i++)
  2. {
  3. var textBox = document.getElementById( "txt_"  + i) 
  4. ...
  5. }
Jan 27 '09 #2
PRR
750 Expert 512MB
@marisenthil
Try this
Expand|Select|Wrap|Line Numbers
  1. int i = 1;
  2.         foreach (Control c in form1.Controls)
  3.         {
  4.             if (c is Button)
  5.             {
  6.                 if (c.ID == "Button"+i.ToString())
  7.                 {
  8.                     ((Button)(c)).Text = "Something";
  9.                 }
  10.             }
  11.         }
  12.  
Jan 27 '09 #3
Frinavale
9,735 Expert Mod 8TB
Also, check out this article on How to use dynamic controls in asp.net.

-Frinny
Jan 27 '09 #4
PRR
750 Expert 512MB
Instead of looping through you could also use FindControl...
Expand|Select|Wrap|Line Numbers
  1. Control c1 = null;
  2.  
  3. c1=FindControl("Button1"); // Here you pass Id of control you are trying to find ..
  4.         if (c1 != null)
  5.         {
  6.             if (c1 is Button)
  7.             {
  8.                 ((Button)(c1)).Text = "Something";
  9.             }
  10.         }
  11.  
Jan 28 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Abraham Luna | last post by:
how do i stop the dynamic validators from breaking explorer if i use a dynamic validator and move to a different control it breaks explorer and i can type in the page when i'm not supposed to....
2
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row...
5
by: c676228 | last post by:
Hi, I guess I am confused. In aspx script, I mean (you won't use Codebehind="enrollinfo.aspx.vb", but mix code with html and code together) You can access user control's property directly. Since I...
0
by: comp974 | last post by:
ok, here is the situation, I am trying to construct a table with several ASP.net 2.0 controls in it during execution time in an VB.net enviroment. For starters, I have a textbox and a linkbutton...
5
by: Anil Gupte | last post by:
How does one access dynamic controls by name (or whatever other means)? I have the following: Dim newbtnPick As New Button newbtnPick.Name = "SliceButton" & CurSliceNum newbtnPick.Location =...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
2
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation...
4
by: =?Utf-8?B?RHlsYW5TbWl0aA==?= | last post by:
I have a WebForm where I'm dynamically creating some controls and I'm having difficulty understanding how the state is being persisted and how to work with it. I've created a simplified example...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...

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.