Solved

asp textboxt visible=false postback

Posted on 2009-07-06
5
207 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 9

Accepted Solution

by:
Rahul Goel ITIL 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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

690 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