Hidden Textbox

Discussion in 'ASP .Net Building Controls' started by Rob T, Jun 10, 2004.

  1. Rob T

    Rob T Guest

    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.
    Rob T, Jun 10, 2004
    #1
    1. Advertising

  2. Rob T

    Jos Guest

    "Rob T" <> wrote in message
    news:%23we$...
    > 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
    Jos, Jun 11, 2004
    #2
    1. Advertising

  3. Rob T

    Shawn B. Guest

    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


    "Jos" <> wrote in message
    news:%...
    >
    > "Rob T" <> wrote in message
    > news:%23we$...
    > > 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
    >
    >
    Shawn B., Jun 11, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rajesh

    Hidden textbox values lost!!

    Rajesh, Sep 5, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    2,437
    Rajesh.V
    Sep 10, 2003
  2. Brent Burkart

    Hidden Textbox

    Brent Burkart, Apr 26, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    5,272
    Steve C. Orr [MVP, MCSD]
    Apr 26, 2005
  3. Brent Burkart

    Hidden Textbox

    Brent Burkart, Apr 26, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    361
    Brent Burkart
    Apr 26, 2005
  4. Rick
    Replies:
    3
    Views:
    8,094
    Alexey Smirnov
    Apr 13, 2010
  5. SolarCanine
    Replies:
    2
    Views:
    251
    SolarCanine
    Sep 20, 2005
Loading...

Share This Page