Solved

asp textboxt visible=false postback

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

11 Experts available now in Live!

Get 1:1 Help Now