Solved

naming convention when refencing controls within a repeater in javascript

Posted on 2014-09-18
3
149 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

690 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