Beginner's question about textboxes,

  • Thread starter Thread starter Toni
  • Start date Start date
T

Toni

Hello,

I have an ASP.NET page that fills a textbox in the load event of the page

textbox1.text = "Some text"

I would like to this page to run in the way that the user could edit the
text in the textbox, and when he clicks a button, this edited text will be
then read from the textbox into a variable like

Dim editedtext as string
editedtext = textbox1.text

But when I run the program like this, the value of the string "editedtext"
is still the same than what was put there in the load event. Could someone
tell me what must be done? Thank you already in advance.

T.S.
 
Hello,
Please apply to the appopriate NG.
microsoft.public.dotnet.framework.aspnet for instance.

regards.
 
Hi Toni,
But when I run the program like this, the value of the string "editedtext"
is still the same than what was put there in the load event. Could ?someone
tell me what must be done? Thank you already in advance.

You just need to check IsPostBack property of the Page

[C#]
if (!IsPostBack)
{
TextBox.Text = "Some text";
}

When you first time open the page IsPostBack is false coz you requested page
with GET methods. When you press any button (or such case) you send POST
data on the server and IsPostBack become true (the second visit).

Regards, Alex Meleta
[TechBlog] http://devkids.blogspot.com

T> editedtext
T>
 
Back
Top