Beginner's question about textboxes,

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.
 
S

Sagamore

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

regards.
 
A

Alex Meleta

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top