Solved

naming convention when refencing controls within a repeater in javascript

Posted on 2014-09-18
3
137 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 Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now