Retrieving form data by name

Discussion in 'ASP .Net' started by andrewbb@gmail.com, Jul 6, 2007.

  1. Guest

    This will likely be the dumbest question of the day, but:

    Me.Request.Form.Item(3) 'works
    Me.Request.Form.Item("txtName") 'doesn't work

    Intellisense shows the full name of the key is:
    ctl00$ContentPlaceHolder1$txtName

    Why is the key not: txtName ?

    Master:
    <form id="form1" runat="server">
    <div>
    <asp:ContentPlaceHolder
    ID="ContentPlaceHolder1" runat="server">
    </asp:ContentPlaceHolder>
    </div>
    </form>

    Page:
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
    runat="server">
    <table style="width: 500px; height: 200px">
    <tr>
    <td style="width: auto;">
    Email address:</td>
    <td style="width: 192px;">
    <asp:TextBox ID="txtEmail" runat="server"
    MaxLength="50" Width="264px"></asp:TextBox></td>
     
    , Jul 6, 2007
    #1
    1. Advertising

  2. You could read your value as
    txtName.Text
    or
    Me.Request.Form.Item(txtName.ClientID)

    "" wrote:

    > This will likely be the dumbest question of the day, but:
    >
    > Me.Request.Form.Item(3) 'works
    > Me.Request.Form.Item("txtName") 'doesn't work
    >
    > Intellisense shows the full name of the key is:
    > ctl00$ContentPlaceHolder1$txtName
    >
    > Why is the key not: txtName ?
    >
    > Master:
    > <form id="form1" runat="server">
    > <div>
    > <asp:ContentPlaceHolder
    > ID="ContentPlaceHolder1" runat="server">
    > </asp:ContentPlaceHolder>
    > </div>
    > </form>
    >
    > Page:
    > <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
    > runat="server">
    > <table style="width: 500px; height: 200px">
    > <tr>
    > <td style="width: auto;">
    > Email address:</td>
    > <td style="width: 192px;">
    > <asp:TextBox ID="txtEmail" runat="server"
    > MaxLength="50" Width="264px"></asp:TextBox></td>
    >
    >
     
    =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?=, Jul 6, 2007
    #2
    1. Advertising

  3. Guest

    Thanks!
     
    , Jul 6, 2007
    #3
  4. Aidy Guest

    Or just use

    txtName.Text

    if viewstate is enabled.

    "Sergey Poberezovskiy" <> wrote
    in message news:...
    > You could read your value as
    > txtName.Text
    > or
    > Me.Request.Form.Item(txtName.ClientID)
    >
    > "" wrote:
    >
    >> This will likely be the dumbest question of the day, but:
    >>
    >> Me.Request.Form.Item(3) 'works
    >> Me.Request.Form.Item("txtName") 'doesn't work
    >>
    >> Intellisense shows the full name of the key is:
    >> ctl00$ContentPlaceHolder1$txtName
    >>
    >> Why is the key not: txtName ?
    >>
    >> Master:
    >> <form id="form1" runat="server">
    >> <div>
    >> <asp:ContentPlaceHolder
    >> ID="ContentPlaceHolder1" runat="server">
    >> </asp:ContentPlaceHolder>
    >> </div>
    >> </form>
    >>
    >> Page:
    >> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
    >> runat="server">
    >> <table style="width: 500px; height: 200px">
    >> <tr>
    >> <td style="width: auto;">
    >> Email address:</td>
    >> <td style="width: 192px;">
    >> <asp:TextBox ID="txtEmail" runat="server"
    >> MaxLength="50" Width="264px"></asp:TextBox></td>
    >>
    >>
     
    Aidy, Jul 6, 2007
    #4
  5. Howdy Aidy,

    Why if viewstate is enabled? It works even if ViewState is disabled, because
    it's equivalent to Request.Form[txt.UniqueID]. TextBox uses viewstate only to
    raise OnTextChanged event.

    Regards
    --
    Milosz


    "Aidy" wrote:

    > Or just use
    >
    > txtName.Text
    >
    > if viewstate is enabled.
    >
    > "Sergey Poberezovskiy" <> wrote
    > in message news:...
    > > You could read your value as
    > > txtName.Text
    > > or
    > > Me.Request.Form.Item(txtName.ClientID)
    > >
    > > "" wrote:
    > >
    > >> This will likely be the dumbest question of the day, but:
    > >>
    > >> Me.Request.Form.Item(3) 'works
    > >> Me.Request.Form.Item("txtName") 'doesn't work
    > >>
    > >> Intellisense shows the full name of the key is:
    > >> ctl00$ContentPlaceHolder1$txtName
    > >>
    > >> Why is the key not: txtName ?
    > >>
    > >> Master:
    > >> <form id="form1" runat="server">
    > >> <div>
    > >> <asp:ContentPlaceHolder
    > >> ID="ContentPlaceHolder1" runat="server">
    > >> </asp:ContentPlaceHolder>
    > >> </div>
    > >> </form>
    > >>
    > >> Page:
    > >> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
    > >> runat="server">
    > >> <table style="width: 500px; height: 200px">
    > >> <tr>
    > >> <td style="width: auto;">
    > >> Email address:</td>
    > >> <td style="width: 192px;">
    > >> <asp:TextBox ID="txtEmail" runat="server"
    > >> MaxLength="50" Width="264px"></asp:TextBox></td>
    > >>
    > >>

    >
    >
    >
     
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, Jul 6, 2007
    #5
  6. Aidy Guest

    I have to admit as I was typing I doubted that you needed the viewstate
    enabled. As you said, it is needed for comparisons for raising events and
    seld-populating but no much else

    "Milosz Skalecki [MCAD]" <> wrote in message
    news:...
    > Howdy Aidy,
    >
    > Why if viewstate is enabled? It works even if ViewState is disabled,
    > because
    > it's equivalent to Request.Form[txt.UniqueID]. TextBox uses viewstate only
    > to
    > raise OnTextChanged event.
    >
    > Regards
    > --
    > Milosz
    >
    >
    > "Aidy" wrote:
    >
    >> Or just use
    >>
    >> txtName.Text
    >>
    >> if viewstate is enabled.
    >>
    >> "Sergey Poberezovskiy" <>
    >> wrote
    >> in message news:...
    >> > You could read your value as
    >> > txtName.Text
    >> > or
    >> > Me.Request.Form.Item(txtName.ClientID)
    >> >
    >> > "" wrote:
    >> >
    >> >> This will likely be the dumbest question of the day, but:
    >> >>
    >> >> Me.Request.Form.Item(3) 'works
    >> >> Me.Request.Form.Item("txtName") 'doesn't work
    >> >>
    >> >> Intellisense shows the full name of the key is:
    >> >> ctl00$ContentPlaceHolder1$txtName
    >> >>
    >> >> Why is the key not: txtName ?
    >> >>
    >> >> Master:
    >> >> <form id="form1" runat="server">
    >> >> <div>
    >> >> <asp:ContentPlaceHolder
    >> >> ID="ContentPlaceHolder1" runat="server">
    >> >> </asp:ContentPlaceHolder>
    >> >> </div>
    >> >> </form>
    >> >>
    >> >> Page:
    >> >> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
    >> >> runat="server">
    >> >> <table style="width: 500px; height: 200px">
    >> >> <tr>
    >> >> <td style="width: auto;">
    >> >> Email address:</td>
    >> >> <td style="width: 192px;">
    >> >> <asp:TextBox ID="txtEmail" runat="server"
    >> >> MaxLength="50" Width="264px"></asp:TextBox></td>
    >> >>
    >> >>

    >>
    >>
    >>
     
    Aidy, Jul 6, 2007
    #6
    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. Dan DeConinck of PixelSmart

    retrieving data from a form

    Dan DeConinck of PixelSmart, Aug 28, 2004, in forum: HTML
    Replies:
    2
    Views:
    421
    WebcastMaker
    Aug 29, 2004
  2. Replies:
    3
    Views:
    8,367
    ducnbyu
    Nov 22, 2006
  3. Java  script  Dude

    IE name="name" & form.name property bug

    Java script Dude, Jun 29, 2004, in forum: Javascript
    Replies:
    5
    Views:
    252
    Java script Dude
    Jun 30, 2004
  4. Pavils Jurjans
    Replies:
    3
    Views:
    194
    Pavils Jurjans
    Mar 18, 2005
  5. Replies:
    6
    Views:
    179
Loading...

Share This Page