HighTechTalks DotNet Forums  

control id and name for postback mechanism

ASP.net Building Controls microsoft.public.dotnet.framework.aspnet.buildingcontrols


Discuss control id and name for postback mechanism in the ASP.net Building Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Martin
 
Posts: n/a

Default control id and name for postback mechanism - 08-18-2006 , 03:26 AM






Hi,

This may be a dumb question, but why is it necessary for a control's id and
name attribute to coincide in order for the postback mechanism to work?

Given that it appears to be necessary, why are they not wired to be the same
value in a base class like control or webcontrol?

Thanks
Martin



Reply With Quote
  #2  
Old   
Teemu Keiski
 
Posts: n/a

Default Re: control id and name for postback mechanism - 08-20-2006 , 03:55 AM






Remember that the value in name attribute matches control's UniqueID, that
is unique ID value so that control can be distinguished from the other
controls, e.g to know which control is in question. UniqueID contains path
of IDs with predefined separators revealing the control path in which the
current control is located in.

Page.FindControl method on the other hand is able to locate the control (and
return reference to it) when it is given a unique id. In other words it
doesn't need to loop through all the controls, evaluating which one's ID
would match. And this is used with postback processing, and is one reason
why name must match UniqueID. It not just finds the control, superfast, but
also causes child control hierarchies to be created (ensures that control
receiving postback is there).

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

"Martin" <x@y.z> wrote

Quote:
Hi,

This may be a dumb question, but why is it necessary for a control's id
and name attribute to coincide in order for the postback mechanism to
work?

Given that it appears to be necessary, why are they not wired to be the
same value in a base class like control or webcontrol?

Thanks
Martin





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.