Hidden Textbox

R

Rob T

I have a user control that need to have a hidden textbox. (I have some JS
that needs to get some info out of it) If I make a standard textbox
(<asp:TextBox ID="txtTest" Runat="server" />) in my control it works
fine....of course it shows it on the screen

It seems so simple...but how the heck do you create a hidden textbox that is
a control?

BTW, I've done hidden textboxes in the past my just doing a
response.write("<input type=hidden ...>") before, but now since I will have
several of the same controls on the page, I need to keep track of the ID of
the box. I figured using a control is nice since it remembers the values it
has on a postback.......

Thanks.

-Rob T.
 
J

Jos

Rob T said:
I have a user control that need to have a hidden textbox. (I have some JS
that needs to get some info out of it) If I make a standard textbox
(<asp:TextBox ID="txtTest" Runat="server" />) in my control it works
fine....of course it shows it on the screen

It seems so simple...but how the heck do you create a hidden textbox that is
a control?

BTW, I've done hidden textboxes in the past my just doing a
response.write("<input type=hidden ...>") before, but now since I will have
several of the same controls on the page, I need to keep track of the ID of
the box. I figured using a control is nice since it remembers the values it
has on a postback.......

There is a hidden HTML server control in ASP.NET:

<input type="hidden" runat="server" id="hidden1" value="whateverValue">

From code, you can get and set its value:
hidden1.value = "test"

Jos
 
S

Shawn B.

In addition, I've also created one on www.planet-source-code.com that
"ghosts" to indicate it is a hidden field among all the other textboxes. I
also created that before I knew you can right-click an html control and
choose "run at server" but I still use the custom control because on some
screens (mainly the search screens for our application) we may have 30 text
boxes and I like to see immediately which ones are hidden and which ones
aren't. Search for "Shawn Bullock" on PSC under the.NET section if you're
interested. Source code in C# and VB.NET.


Thanks,
Shawn
 

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top