Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > requestParams lists the name of the controls and not the ID

Reply
Thread Tools

requestParams lists the name of the controls and not the ID

 
 
TS
Guest
Posts: n/a
 
      06-03-2008
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


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      06-03-2008
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
>
>
>

 
Reply With Quote
 
 
 
 
Steven Cheng [MSFT]
Guest
Posts: n/a
 
      06-04-2008
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/a...eeOfChangingTh
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:
http://www.velocityreviews.com/forums/(E-Mail Removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "TS" <(E-Mail Removed)>
>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
>
>
>


 
Reply With Quote
 
TS
Guest
Posts: n/a
 
      06-04-2008
thanks all!

"Steven Cheng [MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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/a...eeOfChangingTh
> 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 Removed).
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> --------------------
>>From: "TS" <(E-Mail Removed)>
>>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
>>
>>
>>

>



 
Reply With Quote
 
Steven Cheng [MSFT]
Guest
Posts: n/a
 
      06-05-2008
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 Removed).

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

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

<(E-Mail Removed)>
>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]" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> 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/a...eeOfChangingTh
>> 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 Removed).
>>
>> =


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Controls.Count, Controls.IsSynchronized, and Controls.SyncRoot Nathan Sokalski ASP .Net 4 09-05-2007 03:27 AM
Re: Lists of lists and tuples, and finding things within them Daniel Nogradi Python 3 11-10-2006 07:57 AM
List of lists of lists of lists... =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==?= Python 5 05-15-2006 11:47 AM
print("my name is {name}, and {age}-year old {gender}", name, age, gender); =?iso-8859-1?B?bW9vcJk=?= Java 7 01-02-2006 04:39 PM
Re: Urgent! how to get object name, method name and attribute name based on the strings? ding feng C++ 2 06-25-2003 01:18 PM



Advertisments