By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,750 Members | 1,367 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,750 IT Pros & Developers. It's quick & easy.

INamingContainer

P: n/a
I'm having a hard time with INamingContainer.

I'm building a composite control that has a implements an HtmlGenericControl
Div control and an HtmlInputHidden control the Generic control works fine
but the HtmlInputHidden control is giving me all kinds of problems.

My code is something like this:

protected HtmlInputHidden HIH;
protected HtmlGenericControl HGC;

protectected overriden void CreateChildControls(){

Controls.Add(new LiteralControl("Bla Bla Not inportant static tags"));
HIH=new HtmlInputHidden();
HIH.Name=this.ClientID; // this produces the name something as follows
parentControl1:_ct14.
Control.Add(HIH);

<--Initialize the HtmlGenericControl bla bla left out for brevity-->

Now, my problem is this. I need to access HIH.name for a client-side
function (written in javascript) that access this control by its name as
apposed to the DOM document.getElementById(ID) something like
parentControl1_ct14.value. When I set the HIH.Name to the ClientID instead
of getting the expected parentControl1_ct14 I get parentControl:_ct14
(Notice the colon) This colon for some reason behaves like a delimiter in
javascript and returns an exception requiring a ")". I have also tried
using UniqueID but that too returns the same problem. Can someone tell me
what I am doing wrong here? this is driving me crazy and causing all kinds
of grief for me.

Thank you in advance,

Sam-
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
The problem does not look related to INamingContainer. As you are probably
aware, its just a marker interface used so that when the controls are
rendered, the name takes on a heirarchical scheme and the container control
name is pre-pended to the ClientID to make it constant and unique.

If I understand the problem correctly, to access the HIH control, you should
reference its ClientID property value using your client side javascript.
This may require that you set this value using some server side registration
script (eg. setting the value of a hidden control, javascript variable etc.
from the server side) and then have your client side code, pick up that
ClientID, and use it to get a reference to the control you wish to
manipulate via javascript.

--
- Paul Glavich
MVP ASP.NET
http://weblogs.asp.net/pglavich
ASPInsiders member - http://www.aspinsiders.com
"Sam Samnah" <we**********@terraquest123.ca> wrote in message
news:eM**************@tk2msftngp13.phx.gbl...
I'm having a hard time with INamingContainer.

I'm building a composite control that has a implements an
HtmlGenericControl Div control and an HtmlInputHidden control the Generic
control works fine but the HtmlInputHidden control is giving me all kinds
of problems.

My code is something like this:

protected HtmlInputHidden HIH;
protected HtmlGenericControl HGC;

protectected overriden void CreateChildControls(){

Controls.Add(new LiteralControl("Bla Bla Not inportant static tags"));
HIH=new HtmlInputHidden();
HIH.Name=this.ClientID; // this produces the name something as follows
parentControl1:_ct14.
Control.Add(HIH);

<--Initialize the HtmlGenericControl bla bla left out for brevity-->

Now, my problem is this. I need to access HIH.name for a client-side
function (written in javascript) that access this control by its name as
apposed to the DOM document.getElementById(ID) something like
parentControl1_ct14.value. When I set the HIH.Name to the ClientID
instead of getting the expected parentControl1_ct14 I get
parentControl:_ct14 (Notice the colon) This colon for some reason behaves
like a delimiter in javascript and returns an exception requiring a ")".
I have also tried using UniqueID but that too returns the same problem.
Can someone tell me what I am doing wrong here? this is driving me crazy
and causing all kinds of grief for me.

Thank you in advance,

Sam-

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.