Simple question: Retrieve form elements name in content placeholder

Discussion in 'ASP .Net' started by Kees de Winter, May 12, 2006.

  1. Hi,

    If I have a TextBox place inside a content placeholder then at runtime the
    TextBox's name changes to ctl00_ContentPlaceHolder1_tbCity. What is the best
    way to get the value of the TextBox server-side without 'guessing' the name
    in the produced HTML?
    Page.Request("??")

    Thanks
    --
    Kees de Winter
     
    Kees de Winter, May 12, 2006
    #1
    1. Advertising

  2. Reques.Form(myTextBox.UniqueId)

    Karl

    --
    http://www.openmymind.net/
    http://www.fuelindustries.com/


    "Kees de Winter" <nospam> wrote in message
    news:44647e94$0$2030$...
    > Hi,
    >
    > If I have a TextBox place inside a content placeholder then at runtime the
    > TextBox's name changes to ctl00_ContentPlaceHolder1_tbCity. What is the
    > best
    > way to get the value of the TextBox server-side without 'guessing' the
    > name
    > in the produced HTML?
    > Page.Request("??")
    >
    > Thanks
    > --
    > Kees de Winter
    >
    >
     
    Karl Seguin [MVP], May 12, 2006
    #2
    1. Advertising

  3. Thanks Karl,

    Thank you for the quick answer.
    One more question: if the form is posted to another page, then the variable
    myTextBox will be unknown. How to retrieve a Form elements value then?

    Thanks
    --
    Kees de Winter


    "Karl Seguin [MVP]"

    > Reques.Form(myTextBox.UniqueId)
    >
    > Karl
    >
    > --
    > http://www.openmymind.net/
    > http://www.fuelindustries.com/
    >
    >
    > "Kees de Winter" wrote in message
    > news:44647e94$0$2030$...
    > > Hi,
    > >
    > > If I have a TextBox place inside a content placeholder then at runtime

    the
    > > TextBox's name changes to ctl00_ContentPlaceHolder1_tbCity. What is the
    > > best
    > > way to get the value of the TextBox server-side without 'guessing' the
    > > name
    > > in the produced HTML?
    > > Page.Request("??")
    > >
    > > Thanks
    > > --
    > > Kees de Winter
    > >
    > >

    >
    >
     
    Kees de Winter, May 12, 2006
    #3
  4. u don't :)

    2.0 supports crostpass postback.

    The only solution I can think of to get out of your mess is
    (a) don't use server controls
    (b) do some crazy javascript stuff to either change the names or copy values
    into hidden form fields that you do know the name...this solution sucks :)

    Karl

    --
    http://www.openmymind.net/
    http://www.fuelindustries.com/


    "Kees de Winter" <nospam> wrote in message
    news:4464897c$0$2021$...
    > Thanks Karl,
    >
    > Thank you for the quick answer.
    > One more question: if the form is posted to another page, then the
    > variable
    > myTextBox will be unknown. How to retrieve a Form elements value then?
    >
    > Thanks
    > --
    > Kees de Winter
    >
    >
    > "Karl Seguin [MVP]"
    >
    >> Reques.Form(myTextBox.UniqueId)
    >>
    >> Karl
    >>
    >> --
    >> http://www.openmymind.net/
    >> http://www.fuelindustries.com/
    >>
    >>
    >> "Kees de Winter" wrote in message
    >> news:44647e94$0$2030$...
    >> > Hi,
    >> >
    >> > If I have a TextBox place inside a content placeholder then at runtime

    > the
    >> > TextBox's name changes to ctl00_ContentPlaceHolder1_tbCity. What is the
    >> > best
    >> > way to get the value of the TextBox server-side without 'guessing' the
    >> > name
    >> > in the produced HTML?
    >> > Page.Request("??")
    >> >
    >> > Thanks
    >> > --
    >> > Kees de Winter
    >> >
    >> >

    >>
    >>

    >
    >
     
    Karl Seguin [MVP], May 12, 2006
    #4
    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. John
    Replies:
    2
    Views:
    924
  2. Bob
    Replies:
    5
    Views:
    4,873
    clintonG
    Feb 27, 2008
  3. nail

    Build control in a placeholder or like a placeholder

    nail, Sep 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    352
  4. Pavils Jurjans
    Replies:
    3
    Views:
    207
    Pavils Jurjans
    Mar 18, 2005
  5. Replies:
    6
    Views:
    189
Loading...

Share This Page