TextBox control lose their content if visible=false

0 Aufrufe
Direkt zur ersten ungelesenen Nachricht

elsni

ungelesen,
22.07.2005, 06:20:3722.07.05
an
Hi,

I got some hidden textboxes in my web part. They lose their data if
Visible=false, and they keep them if Visible=true.
What can be wrong?
They are defined as a private array of textboxes.

in CreatChildControls:

dokurls[i] = new TextBox();
dokurls[i].ID = "dokurls_" + i;
dokurls[i].Visible = false;
dokurls[i].Enabled = true;
dokurls[i].EnableViewState = true;
this.Controls.Add(dokurls[i]);

They get their value in RenderWebPart().

they are empty again in the Command event routine of a LinkButton.

Thanks in advance
/Stephan

chaserNL

ungelesen,
22.07.2005, 07:02:2622.07.05
an
Nothing is wrong they just do that... in WebParts atleast. I have used
a <div id="hidediv" style="visibility:hidden"> </div> to hide them.
You could prob also do it directly by dokurls[i].Style[visibility] =
"hidden";

Greetings

elsni

ungelesen,
25.07.2005, 03:44:1925.07.05
an
Is that a bug or a featue?

chaserNL

ungelesen,
25.07.2005, 06:15:0425.07.05
an
Well by design.. so a Feature i would say.

elsni

ungelesen,
25.07.2005, 08:20:0425.07.05
an
Great.... No way to keep data in hidden fields...

chaserNL

ungelesen,
25.07.2005, 09:32:1925.07.05
an
There is i told you this in my first reply:
<Control>.Style["visibility"] = "hidden";

as in your case:

elsni

ungelesen,
26.07.2005, 04:15:4626.07.05
an
Sorry, I did not read your answer properly.
Thank you!

But why does it work in a ASP .NET application but not in a web part?

chaserNL

ungelesen,
26.07.2005, 04:35:5326.07.05
an
That i do not know... anyone?

elsni

ungelesen,
26.07.2005, 04:45:1226.07.05
an
I testet setting the style to "hidden", it works!

But then the control take space on the page if they are hidden this
way. If I have about 100 hidden controls it's a lot of space!

chaserNL

ungelesen,
27.07.2005, 03:34:2027.07.05
an
Well that sucks...

You could try setting the Height and Width to 0, or use div's around
your checkboxes.

LiteralControl lc;
lc=new LiteralControl();
lc.Text="<div style=\"visibility:hidden\">";
Controls.Add(lc);

<checkbox>

lc=new LiteralControl();
lc.Text="</div>";
Controls.Add(lc);

elsni

ungelesen,
27.07.2005, 03:56:5427.07.05
an
Sure, very cumbersome. They must have been drunk while designing this
;-)

Thanks

chaserNL

ungelesen,
27.07.2005, 05:09:4427.07.05
an
That would explain it :D

Allen antworten
Dem Autor antworten
Weiterleiten
0 neue Nachrichten