473,394 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

INamingContainer

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
1 1692
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jo Inferis | last post by:
(Disclaimer : I'm pretty new to .NET, so please forgive me if this isn't 100% clear) I know Master pages are coming, but until then I've implemented a version of the page templating solution at...
0
by: Alex Stevens | last post by:
Hi All, I have built a composite user web control and I've NOT implemented INamingContainer. It does implement IPostBackDataHandler to retrieve information entered into the controls when the...
10
by: Natan | last post by:
Is there any possibility to make an ASCX be loaded in an object that does not implement INamingContainer, but mantain the funcionality of events and etc? I know i can`t do this using the current...
3
by: gemel | last post by:
Interface definitions do no not contain implementation, only signtures. That is there real purpose. Here thow we have an Inteface which does not have any implementation code but it has to be...
2
by: Sam Samnah | last post by:
With INamingContainer ChildControl UniqueIDs or ClientIDs are Represented similar to the following: ParentControlID:childControlID Now my problem is the colon ":" used to sperate the Parent...
5
by: PJ | last post by:
Is there a way to prevent the INamingContainer behaviour that prefixes the id of server controls in master pages with the format __. I would prefer to manage the potential id attribute conflicts...
2
by: Martin Robins | last post by:
I have a situation where I need to specify the names for some controls without the parent INamingContainer getting in the way - this is because I am using 2 hidden fields to pass data to another...
0
by: archana | last post by:
Hi all, Can anyone tell me what is use of implementing INamingContainer interfece. I am very much confused about this interface as it has to methods to implement. any help will be truely...
4
by: TS | last post by:
Steven, i lost this message conversation from outlook express and made a post online (see last one on this page). Please answer it as it hasn't been yet. thanks The clientID of our controls...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.