Solved

naming convention when refencing controls within a repeater in javascript

Posted on 2014-09-18
3
147 Views
Last Modified: 2014-10-03
What the naming convention when refencing controls within a repeater in javascript?   If a controls is called "xyz", what's its name in each row of a repeater?
0
Comment
Question by:HLRosenberger
3 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40330930
open the page with a recent web browser, do a right click on a row and choose "Inspect Element"
'welcome !
0
 
LVL 14

Accepted Solution

by:
dejaanbu earned 500 total points
ID: 40334969
in repeater's databound event , you can get the reference of the control in javascript.
for ex:
in the item_datatbound event of the repeater:
Label lblFirstName = (Label) e.Item.FindControl("lblFirstName");
Button btn =(Button)e.Item.FindControl("somebuttonID");                             
 btn.Attributes.Add("onclick","return testfunc('" + lblFirstName.ClientID.ToString() +"');");

Open in new window

in the Javascript:
function testfunc(lblID) 
{ var lbl = document.getElementById(lblID);
alert(lbl.innerText);  /if textbox, use "value" instead of innerText
}

Open in new window

0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 40359750
thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question