Hidden Text boxes

D

DanWeaver

Due to the lack of persistence in a listbox element across postbacks I
have been forced to use textboxes to gather eg removed items (removed
via a javascript) so that the listbox can be repopulated on postback
amongst other things.

I now find (stupidly I didnt test this before) that when an asp text
box is invisible ie visible= false the client side sript that writes
to it shows an error- ie cant write to it. I have tried adding an
attribute ie textbox.Attributes.add of type hidden but to no avail.

Any clues?

Dan
 
E

Eliyahu Goldin

The correct way is to use a hidden input control, as another poster said.

There is still a way of hiding any control and still have it available on
client side and on postbacks. That is to hide it with a css rule
display:none.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
M

Mark Rae

Due to the lack of persistence in a listbox element across postbacks I
have been forced to use textboxes to gather eg removed items (removed
via a javascript) so that the listbox can be repopulated on postback
amongst other things.

I now find (stupidly I didnt test this before) that when an asp text
box is invisible ie visible= false the client side sript that writes
to it shows an error- ie cant write to it.

That's right - controls whose Visible property is false do not actually get
rendered down to the client...
I have tried adding an attribute ie textbox.Attributes.add of type hidden
but to no avail.

You can add pretty much any attribute you like to controls but, unless it's
an attribute which the browser recognises (e.g. onclick, onblur, style etc),
it will simply be ignored client-side.
Any clues?

http://msdn2.microsoft.com/en-au/library/system.web.ui.webcontrols.hiddenfield.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top