Custom control looses data ASP.NET 2.0

S

Shimon Sim

I am working with ASP.NET 2.0
I have user control that has 2 textboxes. On of them is hidden using html
attribute (it is still rendered on the page). The control also has html
button for JavaScript event.
After user clicks on the button browser shows pop up web dialog and allows
user to make select in it. The selection that is displayed in the visible
textbox and key of the selection is stored in hidden text box.

The problem is that after post back and page returns to the browser the
values of the boxes are lost. ( I can read them on server though). I don't
have anything clearing them.

Any ideas? All the EnableViewState set to true (two textbox and the
usercontrol on the page)

Thank you,
Shimon.
 
S

Shimon Sim

Found. For some reason if you set a TextBox ReadOnly = true. It doesn't keep
stateview. In 1.1 behavior was different
 
M

Mr Newbie

Thats a shame as I used to use this, have you also tried this on normal
pages ? You could of course work around this by saving the value manually to
viewstate
 
S

Shimon Sim

There is very easy work around.
First of all you make your textbox ReadOnly = false;
but you add
textBox.Attributes.Add("readonly","true");
That is all.

No I didn't try this on regular pages.
Let me know if it works differently on pages.
Shimon.
 

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,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top