473,394 Members | 1,697 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,394 software developers and data experts.

Wierd: Can't get .text value of textbox

I have a textbox on my webform. I can set it, like txt1.text = "hi", but if
I change the text and click a button to display the current value it RETAINS
the old value. Any ideas?

Any ideas?
Nov 18 '05 #1
3 3805
If you set the value of the Textbox programmatically, then when the Page
Loads it sets it to that value. When you submit it will keep doing it unless
you include some code to tell it to do it on initial load like this:

private Page_Load
{

if(!IsPostBack)
{
txt1.Text = "Hi";

}

}

Not sure of syntax for VB:)
The IsPostBack property of the Page class detects when the request is a
postback. That is it has been submitted after initial load.
Hope this helps,

Frank

"VB Programmer" <Do*****************@jEmail.com> wrote in message
news:Oi**************@TK2MSFTNGP15.phx.gbl...
I have a textbox on my webform. I can set it, like txt1.text = "hi", but if I change the text and click a button to display the current value it RETAINS the old value. Any ideas?

Any ideas?

Nov 18 '05 #2

"VB Programmer" <Do*****************@jEmail.com> wrote in message
news:Oi**************@TK2MSFTNGP15.phx.gbl...
I have a textbox on my webform. I can set it, like txt1.text = "hi", but
if
I change the text and click a button to display the current value it
RETAINS
the old value. Any ideas?

Any ideas?

Before you initailise the page, are you checking to see if the page has been
posted back (ie page.ispostback)? Otherwise you are writing the old value
into the textbox when you intialise the page.

--
Brian Barnes
No Spam Proof e-mail
Use News Groups
Nov 18 '05 #3
You both are correct! Duh.

Thanks so much guys.

"Brian Barnes" <sp****@nospam.com> wrote in message
news:Ot**************@TK2MSFTNGP09.phx.gbl...

"VB Programmer" <Do*****************@jEmail.com> wrote in message
news:Oi**************@TK2MSFTNGP15.phx.gbl...
I have a textbox on my webform. I can set it, like txt1.text = "hi", but
if
I change the text and click a button to display the current value it
RETAINS
the old value. Any ideas?

Any ideas? Before you initailise the page, are you checking to see if the page has

been posted back (ie page.ispostback)? Otherwise you are writing the old value
into the textbox when you intialise the page.

--
Brian Barnes
No Spam Proof e-mail
Use News Groups

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Markus Fischer | last post by:
Hi, I'm experiencing a wierd problem with IE 6 in Windows with two _slightly_ different Version. Give the following HTMl-Code, ideally the output of offsetTop should be "105"; a few pixel...
1
by: paul reed | last post by:
Hello, I am having some weird behavior between two machines...one which is running the 1.1 framework and one which is running 1.0. After opening a child form from a parent...I update the...
1
by: Luis Esteban Valencia | last post by:
Hello. I have a datagird with textboxes on a column item template, I also have 2 other columns that are hidden and I want to retrieve his value. But I havent found how to do it. Thanks very much...
6
by: Roy | last post by:
Hey all, I'm a relative newcomer to asp.net and have 2 simple code snippets below. Everything works fine, I'm just curious if there is a more efficient way to do the job as the update takes quite a...
1
by: dx | last post by:
I'm extremely frustrated with ASP.NET...again! To me this should be as simple as setting oCheckBox.Checked = True.. yet for some reason it isn't. I have a user control (ascx) that that has a...
3
by: Michael Loughry | last post by:
I'm working for a company in Houston developing a web application. At one point in the code, we have to refresh the page, but save what checkboxes have been selected. Since these checkboxes are...
0
by: Paul | last post by:
Hi all, I have a simple custom control with a label and a text box. The text control's value is persisting when I do a post back, so the view state is working, but I cannot access the value in...
1
by: cableguy69 | last post by:
Hello There. I am programming with visual basic within the Excel realm. I have a problem with the way my selected textbox recognizes dates generated from the datepicker. I am from New...
16
by: mj.redfox.mj | last post by:
Can anyone help? I have a textbox which I'm programatically adding by using the following code: txtTest = New TextBox txtTest.ID = "txtLeft" + cntCount.ToString...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.