Solved

asp textboxt visible=false postback

Posted on 2009-07-06
5
202 Views
Last Modified: 2013-12-17
I have an ASP textbox in which I am storing a value in between postback.

When I set the visible property of the textbox to True the value remains between postback. When I set the visible property to False, the stored value in the textbox is not kept.

The view state property of the textbox it set to true.

I am not sure why this is happening, can anybody help?

Thanks
0
Comment
Question by:Mr_Shaw
  • 3
5 Comments
 
LVL 9

Accepted Solution

by:
Rahul Goel earned 500 total points
ID: 24783924
You use Hidden fields for that...Do not use textboxes
0
 

Author Comment

by:Mr_Shaw
ID: 24783940
I thought hidden fields were only in HTML on ASP
0
 

Author Comment

by:Mr_Shaw
ID: 24783944
ah.. spotted it...

i'll give it go.
0
 
LVL 4

Expert Comment

by:vbgb
ID: 24783948
When you set the ASP textbox visible property to false, the server generates the page without the box, which is why any value is lost on postback. If you try to access a hidden textbox using javascript it will throw an error because as far as the browser is concerned the textbox simply doesn't exist.

To save a value on postback you need to replace the textbox with a 'HiddenField'. This exists on the page when rendered to the client browser, but is always hidden. Any value stored in it will be retaiined on poastback, but the user cannot see or edit the value.

0
 

Author Closing Comment

by:Mr_Shaw
ID: 31600091
thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with solving error related to resources file 4 35
Runtime Exceptions when trying to submit data 28 36
Syntax Error 2 41
SSL https .net web site force redirect 3 31
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now