Click here to Skip to main content
16,013,440 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have one textbox and one button control in my ASPX page. Values entered in the textbox should be displayed dynamically.
Posted
Updated 21-Feb-11 7:06am
v4

Ok. So, whats the problem?

In button click event on server side event:
myTextbox.Text = "my dynamic text";

UPDATE:
Based on wait are you asking that some one enters text into the text box, then clicks the button then the value is displayed on the webpage and if they do it again the new value and the previous value(s) are displayed?

This means you want to preserve the earlier text too. Ok.

Codebehind MyPage.aspx.cs:
C#
//define a page level variable OR a hidden field 
// lets name it allValuesOfTextbox
// Now, in button click event:
allValuesOfTextbox += myTextbox.Text ; // if it was a page level variable
someLabelOnWebpage = allValuesOfTextbox; 

allValuesOfTextbox.Value += myTextbox.Text ; // if hidden field
someLabelOnWebpage = allValuesOfTextbox.Value;
 
Share this answer
 
v2
Comments
shanthikalai 21-Feb-11 7:19am    
no i'm nt askig tat,pls understand....at first values entered in the text box should be displayed and again i entered som values in the same textbox it shows next value without disturbing the first.......
Ed Nutting 21-Feb-11 7:21am    
wait are you asking that some one enters ext into the text box, then clicks the button then the value is displayed on the webpage and if they do it again the new value and the previous value(s) are displayed?
shanthikalai 21-Feb-11 7:25am    
yes u r rit
Ankur\m/ 21-Feb-11 8:34am    
Please do not use text-speak (ex - u, r, rit).
This is a technical forum. Please be professional.
Sandeep Mewara 21-Feb-11 8:49am    
:)
Sandeep is right, you just need to add text to a variable, and then assign the variable to the box:

string fullText = "";
void AddText(string text)
{
    fullText += text;
    //or this one if you want to display multiline text
    //don't forget to set the Multiline property of your text box to true in the designer.
    //fullText += Environment.NewLine + text;
    UpdateTextBox();
}
void UpdateTextBox()
{
    textbox.Text = fullText;
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900