Values disappearing in hidden textbox inside repeater

G

Guest

H

Im self learning asp.net, so I may be doing mistakes. But I found something that may be a "bug"...at least for me it looks as inconsistent

I explain myself. I have a repeater and inside of it I have hidden textboxes (visible="False") with values that are set during runtime (I do a loop in a datareader to set them). If I trace the code, you can see that the values are assigned to this textboxes correctly. Once I postback the form I try to get the values from the textboxes that are inside the repeater ( I do a recursive findControl on the repeater to find the control and then grab its value). Instead of getting the value I gave to the textbox during run time I get the value that I set it to during design time in the HTML view ("0")

If I set the control to "visible="true"" for testing purposes the control is read properly in runtime and it has its value is what was expected

What it really puzzles me is that outside the repeater I do the same thing with a textbox that is hidden -in the main form- and I can get the correct value of it, even if the visible value is set to false

Isn't this a strange behaviour in the textbox control? am I doing something wrong? is this what it should happen

any answers are welcome
 
P

Patrice Scribe

I would rather use an htmlInputHidden control...

With "visible" set to false, you won't generate any client side HTML for
this control. You are then not able to retrieve the posted values.
For your small test, are you sure you are retrieving the posted value (could
it be just because the textbox is initialized server side this way) ?

Patrice
--

kornerson said:
Hi

Im self learning asp.net, so I may be doing mistakes. But I found
something that may be a "bug"...at least for me it looks as inconsistent.
I explain myself. I have a repeater and inside of it I have hidden
textboxes (visible="False") with values that are set during runtime (I do a
loop in a datareader to set them). If I trace the code, you can see that the
values are assigned to this textboxes correctly. Once I postback the form I
try to get the values from the textboxes that are inside the repeater ( I do
a recursive findControl on the repeater to find the control and then grab
its value). Instead of getting the value I gave to the textbox during run
time I get the value that I set it to during design time in the HTML view
("0").
If I set the control to "visible="true"" for testing purposes the control
is read properly in runtime and it has its value is what was expected.
What it really puzzles me is that outside the repeater I do the same thing
with a textbox that is hidden -in the main form- and I can get the correct
value of it, even if the visible value is set to false.
Isn't this a strange behaviour in the textbox control? am I doing
something wrong? is this what it should happen?
 

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

Top