requestParams lists the name of the controls and not the ID

  • Thread starter Thread starter TS
  • Start date Start date
T

TS

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
 
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)
 
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:
(e-mail address removed).

==================================================
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.
--------------------
 
thanks all!

Steven Cheng said:
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:
(e-mail address removed).

==================================================
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.
 
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:
(e-mail address removed).

==================================================
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.
--------------------
Subject: Re: requestParams lists the name of the controls and not the ID
Date: Wed, 4 Jun 2008 09:44:13 -0500
 
Back
Top