Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Dale #1
Re: Dynamically create controls with non-hierarchical IDs
You could add a Name attribute to the control and use GetElementsByName to
find it.
Dale
"Simon Wallis" <SimonWallis@discussions.microsoft.com> wrote in message
news:6F76A711-7FF3-4047-A4CB-03D02533FB78@microsoft.com...controls to my page. Each time the repeater.ItemDataBound event fires I> I have a PlaceHolder inside a repeater so that I can dynamically add
create a Label and add it to the PlaceHolder.output, and I want to manipulate this tag using Javascript. In JS I want to>
> Now, when I create this Label, I set the ID to have the dynamic value:
> "lblSubTotal_" + strCurrencyCode;
>
> ASP.NET will turn this Label into a [span] tag in the resulting HTML
get a reference to the tag via its ID value. For example:ID value by prepending a whole bunch of hierarchically-qualified info. For> objCurrencySubtotal = document.getElementById("lblSubTotal_USD");
>
> The problem is that when ASP.NET creates the [span] tag, it modifies the
example, this is the span tag I end up with in the HTML output:id="pbdTemplate__PageTemplate_innerHolder_ctrlBala nces_rptrAggregateTotals__> <span
ctl1_lblSubTotal_USD">ASP.NET from prepending all that hierchical info and force it to use the ID>
> I cannot find this easily using Javascript. Does anyone know how to stop
value I myself assign to the control?>
> Thanks,
> Simon.
Dale Guest
-
Create User Controls dynamically
Howdy, I have a user control that needs to be displayed X amount of times on one page. How is this done? I was thinking of putting it into a... -
How do you create a drop-down hierarchical Data Grid?
Is there a way to dynamically create a drop-down hierarchical data grid? You may want to look at this reference. It has a 1-level hierarchy. ... -
Template controls and hierarchical data
Hi, I have relational data contained in a dataset, say a widget table and a model table. Each widget has a model_id which relates to the primary... -
Dynamically create controls from a network directory tree
I'm trying to create a search page with msIndex service and i want the user to be able to select the directories they would like to search within.... -
How do I dynamically create user controls?
Thanks for any help...! My error is: Object reference not set to an instance of an object. Here's the setup: I have made a user control... -
John Saunders #2
Re: Dynamically create controls with non-hierarchical IDs
"Simon Wallis" <SimonWallis@discussions.microsoft.com> wrote in message
news:6F76A711-7FF3-4047-A4CB-03D02533FB78@microsoft.com...controls to my page. Each time the repeater.ItemDataBound event fires I> I have a PlaceHolder inside a repeater so that I can dynamically add
create a Label and add it to the PlaceHolder.output, and I want to manipulate this tag using Javascript. In JS I want to>
> Now, when I create this Label, I set the ID to have the dynamic value:
> "lblSubTotal_" + strCurrencyCode;
>
> ASP.NET will turn this Label into a [span] tag in the resulting HTML
get a reference to the tag via its ID value. For example:ID value by prepending a whole bunch of hierarchically-qualified info. For> objCurrencySubtotal = document.getElementById("lblSubTotal_USD");
>
> The problem is that when ASP.NET creates the [span] tag, it modifies the
example, this is the span tag I end up with in the HTML output:id="pbdTemplate__PageTemplate_innerHolder_ctrlBala nces_rptrAggregateTotals__> <span
ctl1_lblSubTotal_USD">ASP.NET from prepending all that hierchical info and force it to use the ID>
> I cannot find this easily using Javascript. Does anyone know how to stop
value I myself assign to the control?
Simon,
Another solution is to pass the ID to the JavaScript code. For instance, if
you need to call your JavaScript on a Click event:
lblClickMe.Attributes.Add("onclick",
string.Format("MyJSFunction('{0}');", myLabel.UniqueID));
MyJSFunction will then be able to get the element using getElementById.
--
John Saunders
johnwsaundersiii at hotmail
John Saunders Guest



Reply With Quote

