Form ids in a content placeholder

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob

    Form ids in a content placeholder

    I am trying to obtain values of a submitted form when the form is inside a
    content placeholder via a master page. For example:

    <asp:content contentplacehol derid="contentM ain" runat="server">
    ...
    <asp:TextBox runat="server" id="FirstAndLas tName"></asp:TextBox>
    ...

    However, the identifier for the form element in Request.Form after the form
    is submitted to another page is:

    ctl00%24content Main%24FirstAnd LastName

    Is there a way to prevent form identifers from prefacing the content
    placeholder id? If not, on the form receiving page, how do I obtain the
    field? Request.Form["FirstAndLastNa me"] doesn't work, I am required to
    prepend the ctl100$contentM ain$ stuff.

    Thanks


  • Kevin Spencer

    #2
    Re: Form ids in a content placeholder

    Reference the Control on the server side, rather than the HTML element it
    creates on the client.

    --
    HTH,

    Kevin Spencer
    Chicken Salad Surgeon
    Microsoft MVP

    "Bob" <nobody@nowhere .comwrote in message
    news:%23YpsaP4d IHA.4844@TK2MSF TNGP04.phx.gbl. ..
    >I am trying to obtain values of a submitted form when the form is inside a
    >content placeholder via a master page. For example:
    >
    <asp:content contentplacehol derid="contentM ain" runat="server">
    ...
    <asp:TextBox runat="server" id="FirstAndLas tName"></asp:TextBox>
    ...
    >
    However, the identifier for the form element in Request.Form after the
    form is submitted to another page is:
    >
    ctl00%24content Main%24FirstAnd LastName
    >
    Is there a way to prevent form identifers from prefacing the content
    placeholder id? If not, on the form receiving page, how do I obtain the
    field? Request.Form["FirstAndLastNa me"] doesn't work, I am required to
    prepend the ctl100$contentM ain$ stuff.
    >
    Thanks
    >
    >

    Comment

    • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

      #3
      RE: Form ids in a content placeholder

      create a hidden field that you store the content place holders UniqueID. then
      you will know what to prepend to the controls name. you could also name the
      container (in the codebehind) so it had a fixed name rather than ctl100.

      -- bruce (sqlwork.com)


      "Bob" wrote:
      I am trying to obtain values of a submitted form when the form is inside a
      content placeholder via a master page. For example:
      >
      <asp:content contentplacehol derid="contentM ain" runat="server">
      ...
      <asp:TextBox runat="server" id="FirstAndLas tName"></asp:TextBox>
      ...
      >
      However, the identifier for the form element in Request.Form after the form
      is submitted to another page is:
      >
      ctl00%24content Main%24FirstAnd LastName
      >
      Is there a way to prevent form identifers from prefacing the content
      placeholder id? If not, on the form receiving page, how do I obtain the
      field? Request.Form["FirstAndLastNa me"] doesn't work, I am required to
      prepend the ctl100$contentM ain$ stuff.
      >
      Thanks
      >
      >
      >

      Comment

      Working...