requestParams lists the name of the controls and not the ID

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
 
B

bruce barker

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)
 
S

Steven Cheng [MSFT]

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.
--------------------
 
T

TS

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.
 
S

Steven Cheng [MSFT]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top