UserControl in Template DataColumn

A

Alessandro Rossi

Hi
I developed a usercontrol with a textbox and an htmlInputHidden
When I add my usercontrol in a webform, it works properly
If I add my control in a template column of a datagrid i have some problems
When I load the webform, the usercontrol has a UniqueID like this: "LookUp1:txtRisultato", then I value the text of this textbox with a client-side script. If i post the page, the value saved in the textbox.text is null, but i see that the UniqueID is changed, and now is "DataGrid1:LookUp1:txtRisultato"
How can i refer to my usercontrol with an ID which doesn't changes
Why the UniqueID changes

P.S. I noticed that if I value the textbox sending the right ID (DataGrid1:LookUp1:txtRisultato) the post is made properl

Thank yo
Alessandro Rossi
 
A

Alessandro Zifiglio

Alessandro to Alessandro ;P
hi, The dataGrid is a container control. Controls that can act as containers
for other controls generate a naming container, or an ID namespace, for
their child controls. By providing this naming container, controls can
guarantee that ID attributes of their child controls are unique within the
entire application. (Controls generate a naming container by implementing
the INamingContainer interface.)

Note : As a rule, you should not write code that references controls using
the value of the generated UniqueID property. You can treat the UniqueID
property as a handle (for example, by passing it to a process), but you
should not rely on it having a specific structure.
Ok thats as far as copy and paste goes, so if you want to reference the
entire article in the docs here is the link :
http://msdn.microsoft.com/library/d...n/html/vbconwebformscontrolidentification.asp

I had discussed a work around a few months back within the groups. Reference
it and see if that works for you as well. The js code i wrote was a little
specific to that particular users needs, to whom i had replied but with
small modifications you shouldnt have a problem adapting that to your own
code. If worst, atleast it should give you some ideas on how to proceed :)
heres the post :
http://groups.google.com/groups?hl=...23585%24i_5.17373%40news.edisontel.com&rnum=3

Alessandro

Alessandro Rossi said:
Hi,
I developed a usercontrol with a textbox and an htmlInputHidden.
When I add my usercontrol in a webform, it works properly.
If I add my control in a template column of a datagrid i have some problems:
When I load the webform, the usercontrol has a UniqueID like this:
"LookUp1:txtRisultato", then I value the text of this textbox with a
client-side script. If i post the page, the value saved in the textbox.text
is null, but i see that the UniqueID is changed, and now is
"DataGrid1:LookUp1:txtRisultato".
How can i refer to my usercontrol with an ID which doesn't changes?
Why the UniqueID changes?

P.S. I noticed that if I value the textbox sending the right ID
(DataGrid1:LookUp1:txtRisultato) the post is made properly
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top