디자인을 할 때, 라벨이있는 데이터리스트가 있습니다. 로드 할 때 10 개의 레이블이 있습니다 (목록의 데이터 소스에는 10 개의 값 유형 int가 있습니다). 나는 내가 클릭하는 레이블의 가치를 원한다. 나는 내가 2 문제를 해결해야한다고 생각한다. 1. 클릭 한 컨트롤 (데이터리스트 안의 레이블)을 찾는다. 2. 가치를 얻으십시오. Javascript로 데이터리스트에서 클릭 한 아이템의 가치를 얻으십시오
protected void Page_Load(object sender, EventArgs e)
{
List<int> list = new List<int>();
for (int i = 0; i < 10; i++)
{
list.Add(i);
}
int a=1;
DataList1.DataSource = list;
DataList1.DataBind();
foreach (DataListItem item in DataList1.Items)
{
((Label)item.FindControl("Label1")).Text = a.ToString();
if ((Convert.ToInt32(((Label)item.FindControl("Label1")).Text)) % 2 != 0)
{
((Label)item.FindControl("Label1")).BackColor = System.Drawing.Color.Gray;
}
((Label)item.FindControl("Label1")).Attributes.Add("onclick", "run();");
a++;
}
이
가 여기 내 실행() 함수function run() {
$("#Panel1").scrollTop(100*gt1);
}
, 난 GT1 클릭 라벨의 가치를 원한다. 이 this 키워드를 사용하여와 자바 스크립트 이벤트를 바인딩하면서 (내 영어에 대한 SR) 돕는
감사
. 시도해 보았지만 .valueOf()는 .value를 볼 수없고 작동하지 않습니다. – minhminh265
값 대신 .innerText를 시도하고 작동하는지 알려주세요. – Adil
안녕하세요, Adil,), 내가해야 할 일 – minhminh265