Getting the textbox value after postback in runtime created textbox

Getting the textbox value after postback in runtime created textbox

I have created around 30 controls in a control array like txtremarks1,txtremarks2,txtremarks3.....txtremarks30. in runtime.
When i am posting the server back.I want to get the values but i dont know how to do.
Can anybody please help me in this
Note:I know how to use request.form("") but i dont want to use it.I also have some labels.I want to get the text in label.
Thanks for the help in advance i need it in urgggent
Vishal Murthy
2/19/2005 11:55:31 AM 93655 articles. 5 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 59

In order to get value of dynamically created controls you must recreate it on each postback (in page_init or page_load)other wise you will have to use Request.Forms to access its value (in case of labels yo can use hidden fields)

Another option is to create those in DataGrid or datalist by binding your array to Datagrid/datalist and then loop through datagrid/datalist to get values of your textboxes/labels.
Jigar Desai
Do not forget to "Mark as Answer" on the post that helped you.
2/19/2005 2:45:24 PM

you would need to recreate the controls on postback (in same order) and add them to the Controls collection by the time Load event happens (postback data loading happens after Load event). That way they'd be able to restore their state from postback data and you could access the values via these controls instances themselves.
You should check this article:
Understanding ASp.NET ViewState
Pay special attention to sections which cover dynamical controls (and refer to other articles). Basically in your case, it's about postback data, not ViewState, with textBox but principle is the same.

Teemu Keiski
Finland, EU
2/19/2005 5:26:30 PM
Thanks it is very useful.But i still want to knwo how to acess the controls after post back programatically.Can you pls tell me how.Give me an example for doing it dynamically
Vishal Murthy
2/21/2005 3:07:54 PM
Wouldn't it be than as simple as re-looping though the the control array? Because postback data 2nd try loading happens after Page_Load, you can't access the data in Page_Load if you create the controls in that stage, but you have to do it later, prerender or some postback event being a good example.

Here is an example of doing it literally with an array with (if you rely on IDs, you can do it with just Controls collection)

Private arrControls(25) As TextBox
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
For i = 0 To arrControls.Length - 1
'Create a TextBox
Dim txt As New TextBox
txt.ID = "txt" & i.ToString()
'Add its reference to the array
arrControls(i) = txt
'Add it to the Form
End Sub
Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
'As an example we read the data out from TextBoxes
'In PreRender on postbacks
If IsPostBack Then
Dim i As Integer
Dim currtxt As TextBox
For i = 0 To arrControls.Length - 1
currtxt = arrControls(i)
Response.Write("Value in TextBox " & i.ToString() & " = " & currtxt.Text & "<br>")
End If
End Sub


Teemu Keiski
Finland, EU
2/21/2005 5:01:58 PM

Similar Artilces:

How to get the Value from the Textbox ?Textbox is created by using add control function.
  Dim textWG As New HtmlInputText textWG.text="Wage Rate" textWG.ID = "txtWG" me.control.add(textWG) i write this code at form load.moreover this form have one save button to save the value from the "txtWG" to database this textbox will be appear when form finish load.but after click save button the value cant be save into database. tat textbox become empty when user click the save button. how can i get the value from that textbox ? Please advice me.Thank you You are using a HTML control and by default, HTML controls dont have a mechanism to pres...

create a textbox dynamically at runtime how visible that textbox
hi to all In my application i created a textbox dynamically at runtime how visible that textbox. please guide me.   by devan.g     TextBox1 = new TextBox();    TextBox1.ID = "TextBox1";    TextBox1.Style["Position"] = "Absolute";    TextBox1.Style["Top"] = "25px";    TextBox1.Style["Left"] = "100px";    Form1.Controls.Add(TextBox1); Hope it helps.-Manas=======================================If this post is useful to y...

HTML textboxes appear but not web form textboxes
Hi all, I'm new to all this and I tested it by creating a new project, and clicking and dragging an asp textbox onto the aspx page. Upon clicking "Build and Browse" the asp textbox does not appear at all. So I double checked, and yeah, Visible was set to true. So I tried clicking and dragging a normal textbox and strangely, the html textbox does appear on the screen. Please help on how I can make the ASP textbox appear. I constructed a webform entirely of ASP textboxes and ASP buttons and nothing on the page appears. Is there anything I need to add/remove on the con...

hei guys, i need help on my application, i'm using C#.NET as front-ed and SQL as back-end, aside from a datagrid, i want to display my data using textboxes and not a datagrid, i can do it using Visual Basic 6 but since i'm a newbee at C#.NET i don't know how to do it, specially the codes, can anyone help me with it? thank you in advance! If you are doing windows development, i would suggest using 'DataForm wizard' (Use Solution Explorer-->Rightclick project-->Add new Item-->New DataForm). It will guide you through steps. If you are doing web apps. Use quickstart to learn them. h...

How to get textbox value when textbox properties is readonly or enabled false
Hi ,I have one problem, If u have idea please solve  itTo dispaly canlendercontrol iam using ajax canlender control, after selecting dateof birth into textboxIn textbox keeping textbox properites as readonly or enabled equal false,  getting that textbox value into lable,  ThanksRamesh  Just get the Textbox.Text value?Don't forget to click "Mark as Answer" on the post that helped you. If I understand you correctly, you have a textbox that is disabled/readonly. You use some code to change the value in the textbox, and you want that value to be returne...

Dynamically creating textboxes, then getting values
I am learning, but have developed quiet a bit in php. I'm having trouble finding a solution to something really simple in php. Me.lblTracking.Text = "&lt;table><tr><td colspan='3'>Destination Information</td></tr>" Me.lblTracking.Text += "&lt;tr><td>#</td><td>Tracking #</td></tr>" While (i < 4) Me.lblTracking.Text += "&lt;tr>" Me.lblTracking.Text += "&lt;td>Package " & i & ":</td><td><input type='text' name='Tracking[" & i &a...

Getting values from dynamically created textboxes
Hello, I'm creating a textboxes boxes dynamically when the user presses a button. I'm then adding the textbox to a placeholder. After the user enters data, I want to get the value that they entered, but I'm having trouble. The second method ReadTextBoxes is also being triggered by a button. The problem is that if they user chooses to had 3 new textboxes in the first method, the placeholder will contain 3 controls, but then when I click the button to read the textboxes, the placeholder is showing zero controls. What am I doing wrong? Thanks// This creates the textb...

getting the value of a postback for a readonly textbox
hi guys, i have a textbox, i set as readonly or disabled. But when i do a postback, i cant seem to read the value of the textbox, either when disabled or postback is used. I tried adding this  TextBox_Groups.Enabled = true;        TextBox_Groups.ReadOnly = false; but it still doesnt work, pls help Ehi  The ReadOnly or the disabled TextBox will ingore the Newly submitted value , However , you can get the new value like this :TextBox1.Text=Request.Form(TextBox1.UniqueId)Read my blog post for more information. Regards,Anas Ghanem.Note:Please ...

Convert Web.UI.WebControls.TextBox to Windows.Forms.TextBox
 I am trying to take user selected text from a textbox and save that portion to a string value, but the only method I have found involves using the System.Windows.Forms namespace and since I am using the FindControl method to pull the text box control from a form view, it throws a "can not convert webcontrol to form" error at me.  So far I have been able to bring the form view controls into the code behind page, but I still have the problem of grabbing the selected text.  Here is my code:         Dim textBox As System.Web.UI.WebCont...

Using the Textbox.Text on Dynmaicly Created Textboxes in VB.Net
I found a script that i modified to create textbox fields Dynamicly.  I am now faced with the delimia of figuring out a way to pull the data in those dynamicly created fields.  Since they are not defined, I have not found a way to use a variable to pull the data. Here is the code .aspx   <%@ Page Language="VB" AutoEventWireup="false" CodeFile="DynamicTextboxes.aspx.vb" Inherits="DynamicTextboxes" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "

problem with get value from textbox after get it value in load page
hi every one  i have problem with my web site when i get textbox value in load page   and Changed textbox the page do not take last value .   it take value in load page   this is code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)   TextBox1.Text = "aa" End SubProtected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) MsgBox(TextBox1.Text) End Sub   when i press button message write "aa" while i changed the textbox   please if enyone knowen help me &nbs...

How to get values from dynamically created textboxes?
I have some code in my code behind file that dynamically generates textboxes according to the number of times a user clicks on a button.When the user enters data into these textboxes,how do i get the data that is from these dynamically generated textboxes? Moose, You can use the below code and the Dynamic IDs of the controls you've created to get the values... ' Variables Dim oTxt As Web.UI.WebControls.TextBox Dim sVar$ ' Assign Control oTxt = Me.FindControl("DynamicControlID") ' Assign Value sVar...

problem while getting values from dynamically created textboxes
 Hi FriendsI have created some text boxes dynamically and I have problem while accessing their changed values. And I am using the following code. 1 TextBox t =(TextBox) this.form1.FindControl("field1"); 2 string name = t.Text;   When I try to execute the second line i.e. getting values from the text box, it results with Object reference not set to an instance of object. field1, fiedl2.... all are valid text box ids and they are present in the to solve this? If you are using master page then field1 is changed to other name. Generally for objec...

why value not updated in the duynamically created textbox after postback?
 Hi, I have problem with the followign code. Can anyone tell me how to make the dynamically created textbox2 get the markup:     <form id="form1" runat="server" enableviewstate=false>    <div style=" font-size:larger; font-weight:bolder">        <asp:TextBox  ID="txt1" Text="" runat="server"></asp:TextBox>        <asp:Button ID="Button1" runat="server" Text="Button" ...

Get value of textbox created by javascript at backend
I need to create a button to dynamically insert new row in a table and each cell is a textbox.function insRow() { var length = getRowCount();var x=document.getElementById('myTable').insertRow(0); var y=x.insertCell(0);var id1 = "rowID" + length.toString() + "0";y.innerHTML = "<input id=\"" + id1 + "\" type=\"text\" size=\"10\"></input>"; } My problem is how can I get the value of the textbox at the backend by clicking a server control button?  Why Request.Form["rowID00"] alw...

How to get the value of a dynamically created textbox control
Hi,  Can anyone tell me how to get the entered value from a dynamically created textbox apart from getting it from the TextChanged eventhandler? Regards, Vidya Friend, check this thread as similar scenario is discussed over Another one Good luck!Please Don't forget to click "Mark as Answer" on the post that helped you.This can be beneficial to other community members reading the thread.  use Request["TextBoxId"] to get the value entered in it....Also white creating it rememb...

Create textbox dynamically but can not get the value?
Hi~~ I had one panel and two buttons on my page. Button1 is for "Create Textbox" , button2 is for "Get values". I got a error message when I click button2. The message is "Object reference not set to an instance of an object."  It can not find the textbox that I created dynaically. Hope someone knows how to fix this?? Thanks all....  Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click        Dim i As Long       ...

form getting old textbox.text values
I've got a form that when loaded loads it's values from the database and then allows you to edit them (using textbox controls). When you click save it adds what I would think should be the newly edited values into the parameters and updates the database. However it is instead loading the values prior to them being changed rather than the current values in the text boxes. Anybody know what would cause this?Could be WAAAY off in any suggestions I give in posts, so be on the lookout for stupidity :P As you have  not included any code samples, I can only suggest a possibility.Check...

How to insert value in Database from Textbox (created at runtime)?
Hi I am creating let say 5 textbox on button clik  in 2 Panel on SamePage and now i want to insert data from Both of them with the help of 2nd Button?  how ? Try like this ... take a user control with 1 text box and in OnClick event of the button repeat the loop for required number of times i.e,the no.of text boxes you want to add. And then get the ids of controls added dynamically and then proceed to insert them to DBRegards,Ram Reddy Mekha, +91-994-840-4315http://abhiramreddymekha.blogspot.comPlease Mark as Answer if the post helps you. Hi, Set the Id of t...

How to get Textbox value in web user control?
Hi friends,I created a web user control with only one textbox.(textbox.ascx) and textbox id=" txtSimple"textbox user control having some property. another user control with button(button.ascx) next i use two textbox usercontrol and one button usercontrol in sample.aspx. when i click button at that time call the required field validate property in textbox user property have following code.public bool RequireValidate    {        set        {     &nbs...

How do I keep the value for a textbox in the textbox when the form resets for the next insertion using Details View?
I'm using Details View to insert data to the database. First up one form is visible to enter product details. When that save to the database I get the new primary key using "SELECT MAX(ProductID) FROM Product" (probably not the best way but it works so long as no one else is inserting data at the same time). The first form is hidden and the next form is shown. The primary key is inserted into the ProductID text box and the details for the new items for the product are entered and then saved to the database. All good. BUT when the insert button is clicked on the second form and ...

Cannot get value from an input textbox to a listbox web control??
I am about to go nuts because I really have not done any Asp.Net programming up until now. I have mainly done desktop applications. I am trying to take the textbox in the page and pass the contents of it to the listbox on the same page. I cannot get the values from the textbox to the listbox. Below is my code for the aspx page and also for my code behind page. Can someone please tell and show me where I am going wrong? aspx page:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AspNetPolyDraw.Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML...

Get values set by javascript to .net enabled textbox
I have a bit of javasript that writes a value to a text box.  The text box is read only. Textbox code:<input type="text" id="txtColor1" runat="server" readonly="readonly" size="6" /> Snippet from javascript functioncolorBox = document.getElementById('<%= txtColor1.ClientID %>');colorBox.value = colorCode;  Code behind:string color1 = txtColor1.Value Whenever I attempt to get the value out of the text box after it has been changed by the javascript, it always reverts back to the old data and not the new. Anyo...

Custom web control. Get Textbox.text value
Hi I have created a custom web control that extends the CheckBoxList control. It basically is a CheckBoxList control that has a TextBox added to the end of each CheckBox. It looks like the following after it has being bound to a database table column. I need to be able to retrieve the values in the corresponding TextBox when a CheckBox is selected. I tried storing each TextBox in an ArrayList but it is always empty when I try and check it. I am pretty new to ASP and am obviously missing something. Has anybody here got any tips or ideas on how I could retrieve the data from the TextBoxes...

Web resources about - Getting the textbox value after postback in runtime created textbox -

HasOffers Customers and Partners Event - Postback 2013 Tickets, Seattle - Eventbrite
This is going to be an incredible event with some of the smartest people in user acquisition, publishing, and performance advertising. Look ...

GeekWire Calendar Picks: Postback 2015, Hack the Dot Seattle, and more
Fast-growing Seattle startup Tune is holding its annual marketing conference, Postback 2015, at Seattle Center July 23 – 24. At last year’s event ...

ASP.NET MVC Framework - Wikipedia, the free encyclopedia
Based on ASP.NET , ASP.NET MVC allows software developers to build a web application as a composition of three roles: Model , View and Controller ...

Bentours - Travel Specialist Australia - Hotels, Tours, Flights, Cruises & Packages in Scandinavia, Russia ...
Bentours is a leading Travel Agent based in Australia. We fulfill our client's dream to explore and discover amazing travel destinations.

Amitech Business Solutions
Amitech Business Solutions, Creative Technology Startup ventures , Innovative IT company of India, trendround

Drink of the Week - Logicum
Logicum It's Logical to share Menu Skip to content Home Contests Food Recipes Drink of the Week Health Technology Sports Space World Day Weapons ...

Login An Adworkz Publisher gets paid for driving sales and leads to Advertiser Campaigns. Browse the network to find a campaign that matches ...

Sitefinity 4 Calendar Widget Released!
August 28th, 2011 I work for a software firm in Fort Wayne, IN. For the longest time, we used Sitefinity 3 as our standard content management ...

Second state of the Belgian Twitosphere
On April 17, 2007 I published the first state of the Twitosphere in Belgium , my home country. With this new state of the Twitosphere I want ...

Resources last updated: 2/17/2016 4:56:29 PM