requestParams lists the name of the controls and not the ID

Discussion in 'ASP .Net' started by TS, Jun 3, 2008.

  1. TS

    TS Guest

    i am wondering why the name of the controls are listed in parameters of
    request object instead of ID. The name always uses the default '$' for
    encapsulations and the ID uses '_'. When i use
    Page.ClientScript.RegisterHiddenField it renders the same value for name and
    id, which is the '_' for both. This is causing my hidden fields to appear in
    request context using '_' separators while all other controls use the '$'.

    I have a framework of classes that rely on finding the '$' and interpret '_'
    differently. Is there any way i can make
    Page.ClientScript.RegisterHiddenField use $ for name value and keep ID as
    '_'?

    what other options do i have?

    thanks
    TS, Jun 3, 2008
    #1
    1. Advertising

  2. TS

    bruce barker Guest

    the browser postbacks the name, not the id of form controls. under w3c rules,
    a "$" is not legal character in an id attribute (which is why they are
    changed).

    ..net uses "$" to mark a control as a child control of a naming container.
    RegisterHiddenField does not support naming containers, so it makes the name
    and id the same. (its just a name/value dictionary so there is nowhere to
    store a seperate name/id).

    you will have to render the hidden fields yourself if you want them
    different. i'd make a custom control that supported a list of hidden fields
    (place it right after the form (master page is ideal). then a static method
    that located the control, and added a field to the list.


    -- bruce (sqlwork.com)


    "TS" wrote:

    > i am wondering why the name of the controls are listed in parameters of
    > request object instead of ID. The name always uses the default '$' for
    > encapsulations and the ID uses '_'. When i use
    > Page.ClientScript.RegisterHiddenField it renders the same value for name and
    > id, which is the '_' for both. This is causing my hidden fields to appear in
    > request context using '_' separators while all other controls use the '$'.
    >
    > I have a framework of classes that rely on finding the '$' and interpret '_'
    > differently. Is there any way i can make
    > Page.ClientScript.RegisterHiddenField use $ for name value and keep ID as
    > '_'?
    >
    > what other options do i have?
    >
    > thanks
    >
    >
    >
    bruce barker, Jun 3, 2008
    #2
    1. Advertising

  3. Hi TS,

    Yes, as Bruce has explained. The html form will always post those html
    input fields via its "name" attribute. "ID" attribute is not used for
    identifying form fields, it is used for client-side script language or DOM
    model to reference each html element.

    ASP.NET built-in use '$' char as control ID separator (for nested control
    hierarchy). Are you adding hiddenfield inside some other control? If you
    add it at page's top level, it should not contains such separator char.
    Also, so far for the separator char, you can override ASP.NET Control
    class's "IdSeparator" property to change it. However, changing it will
    cause postback not work and here is a web article mentioned on this:

    #The Odyssee of changing the idSeperator in Asp.net 2.0
    http://code4ward.net/cs2/blogs/cmn/archive/2006/05/17/TheOdysseeOfChangingTh
    eIdSeperatorInAspNet2.aspx

    Therefore, we should avoid changing this separator if possible.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------
    >From: "TS" <>
    >Subject: requestParams lists the name of the controls and not the ID
    >Date: Tue, 3 Jun 2008 08:26:38 -0500


    >i am wondering why the name of the controls are listed in parameters of
    >request object instead of ID. The name always uses the default '$' for
    >encapsulations and the ID uses '_'. When i use
    >Page.ClientScript.RegisterHiddenField it renders the same value for name

    and
    >id, which is the '_' for both. This is causing my hidden fields to appear

    in
    >request context using '_' separators while all other controls use the '$'.
    >
    >I have a framework of classes that rely on finding the '$' and interpret

    '_'
    >differently. Is there any way i can make
    >Page.ClientScript.RegisterHiddenField use $ for name value and keep ID as
    >'_'?
    >
    >what other options do i have?
    >
    >thanks
    >
    >
    >
    Steven Cheng [MSFT], Jun 4, 2008
    #3
  4. TS

    TS Guest

    thanks all!

    "Steven Cheng [MSFT]" <> wrote in message
    news:...
    > Hi TS,
    >
    > Yes, as Bruce has explained. The html form will always post those html
    > input fields via its "name" attribute. "ID" attribute is not used for
    > identifying form fields, it is used for client-side script language or DOM
    > model to reference each html element.
    >
    > ASP.NET built-in use '$' char as control ID separator (for nested control
    > hierarchy). Are you adding hiddenfield inside some other control? If you
    > add it at page's top level, it should not contains such separator char.
    > Also, so far for the separator char, you can override ASP.NET Control
    > class's "IdSeparator" property to change it. However, changing it will
    > cause postback not work and here is a web article mentioned on this:
    >
    > #The Odyssee of changing the idSeperator in Asp.net 2.0
    > http://code4ward.net/cs2/blogs/cmn/archive/2006/05/17/TheOdysseeOfChangingTh
    > eIdSeperatorInAspNet2.aspx
    >
    > Therefore, we should avoid changing this separator if possible.
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    > Delighting our customers is our #1 priority. We welcome your comments and
    > suggestions about how we can improve the support we provide to you. Please
    > feel free to let my manager know what you think of the level of service
    > provided. You can send feedback directly to my manager at:
    > .
    >
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > ications.
    >
    > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 1 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions or complex
    > project analysis and dump analysis issues. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/subscriptions/support/default.aspx.
    > ==================================================
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    > --------------------
    >>From: "TS" <>
    >>Subject: requestParams lists the name of the controls and not the ID
    >>Date: Tue, 3 Jun 2008 08:26:38 -0500

    >
    >>i am wondering why the name of the controls are listed in parameters of
    >>request object instead of ID. The name always uses the default '$' for
    >>encapsulations and the ID uses '_'. When i use
    >>Page.ClientScript.RegisterHiddenField it renders the same value for name

    > and
    >>id, which is the '_' for both. This is causing my hidden fields to appear

    > in
    >>request context using '_' separators while all other controls use the '$'.
    >>
    >>I have a framework of classes that rely on finding the '$' and interpret

    > '_'
    >>differently. Is there any way i can make
    >>Page.ClientScript.RegisterHiddenField use $ for name value and keep ID as
    >>'_'?
    >>
    >>what other options do i have?
    >>
    >>thanks
    >>
    >>
    >>

    >
    TS, Jun 4, 2008
    #4
  5. You're welcome TS,

    If you have any continuous questions, welcome to post here.

    Sincerely,

    Steven Cheng
    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------
    >From: "TS" <>
    >References: <>

    <>
    >Subject: Re: requestParams lists the name of the controls and not the ID
    >Date: Wed, 4 Jun 2008 09:44:13 -0500


    >
    >thanks all!
    >
    >"Steven Cheng [MSFT]" <> wrote in message
    >news:...
    >> Hi TS,
    >>
    >> Yes, as Bruce has explained. The html form will always post those html
    >> input fields via its "name" attribute. "ID" attribute is not used for
    >> identifying form fields, it is used for client-side script language or

    DOM
    >> model to reference each html element.
    >>
    >> ASP.NET built-in use '$' char as control ID separator (for nested control
    >> hierarchy). Are you adding hiddenfield inside some other control? If you
    >> add it at page's top level, it should not contains such separator char.
    >> Also, so far for the separator char, you can override ASP.NET Control
    >> class's "IdSeparator" property to change it. However, changing it will
    >> cause postback not work and here is a web article mentioned on this:
    >>
    >> #The Odyssee of changing the idSeperator in Asp.net 2.0
    >>

    http://code4ward.net/cs2/blogs/cmn/archive/2006/05/17/TheOdysseeOfChangingTh
    >> eIdSeperatorInAspNet2.aspx
    >>
    >> Therefore, we should avoid changing this separator if possible.
    >>
    >> Sincerely,
    >>
    >> Steven Cheng
    >>
    >> Microsoft MSDN Online Support Lead
    >>
    >>
    >> Delighting our customers is our #1 priority. We welcome your comments and
    >> suggestions about how we can improve the support we provide to you.

    Please
    >> feel free to let my manager know what you think of the level of service
    >> provided. You can send feedback directly to my manager at:
    >> .
    >>
    >> =
    Steven Cheng [MSFT], Jun 5, 2008
    #5
    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. =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==

    List of lists of lists of lists...

    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==, May 8, 2006, in forum: Python
    Replies:
    5
    Views:
    384
    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==
    May 15, 2006
  2. Daniel Nogradi
    Replies:
    3
    Views:
    342
    Dennis Lee Bieber
    Nov 10, 2006
  3. Gabriel Zachmann

    Bug with lists of pairs of lists and append()

    Gabriel Zachmann, Sep 28, 2007, in forum: Python
    Replies:
    2
    Views:
    224
    Gabriel Zachmann
    Oct 1, 2007
  4. Gabriel Zachmann

    Bug with lists of pairs of lists and append()

    Gabriel Zachmann, Sep 28, 2007, in forum: Python
    Replies:
    5
    Views:
    257
    Gabriel Zachmann
    Oct 1, 2007
  5. antar2
    Replies:
    2
    Views:
    377
    Bighead
    Jul 17, 2008
Loading...

Share This Page