Solved

naming convention when refencing controls within a repeater in javascript

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…

832 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