Solved

naming convention when refencing controls within a repeater in javascript

Posted on 2014-09-18
3
145 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Head to not include on scroll 4 23
binding event to form in window.open 9 38
Filktering Alphabetically 8 31
Override MS CSS in SharePoint Online Modal Form 19 45
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

828 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