Solved

asp textboxt visible=false postback

Posted on 2009-07-06
5
205 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 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
API v SOA 8 42
Asp.Net Session Question 2 36
Visual C# Windows Project - Clone Form 4 26
Import a excel sheet in a grid 2 13
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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