2013-06-28 2 views
0

속성 및 그 세포 내에서 내가 같은 속성을 가진 텍스트 상자를 추가 특정 행을 찾기 당연히 고유 한 ID로 MoveInDateEle는 테이블 내에서 그 텍스트 상자의 모든 수집 및내가 셀을 추가 테이블 행 내에서, 내 asp.net 양식에 jQuery를

var currentRow = $("[componentname*='tbMoveInDate']").parent().parent(); 

인 나에게 모든 행을주는이 시점에서

function updateMoveInDate() { 
    var MoveInDateEle = $("[componentname*='tbMoveInDate']"); 
} 

- 내 자바 스크립트 내에서

나는이 기능을 가지고있다. 내 특정 행은 아닙니다.

내가 작업중인 특정 텍스트 상자와 해당 컨트롤과 관련된 특정 거주자 ID 및 하우스 ID를 얻는 방법은 무엇입니까?

tb.Attributes.Add("onchange", "updateMoveInDate(this)"; 

과 같은 JS 기능 :

+0

당신은 당신이 작업 또는 어떤 '의미 with' 작업 않는 행을 클릭하고 있습니까? 텍스트 상자에 초점을 맞 춥니 다? 조금 더 설명해 주시겠습니까? 감사합니다 – edhedges

답변

1

tb.Attributes.Add("onchange", "updateMoveInDate(this)"; 

그리고

function updateMoveInDate(txt) { 
    var $txt = $(txt); 
    var $row = $txt.closest('tr'); 
    var residentId = $row.attr('residentId'); 
    var houseId = $row.attr('houseId'); 
} 
,
+0

완벽. 감사! – duckmike

2

는이 같은 C# 코드 수정 당신이 할 수있는

// obj here refers to the current textbox in the scope 
// on which the on-change event had occurred... 
function updateMoveInDate(obj) { 
    var currentRow = $(obj).closest('tr'); 
} 
+0

@edhedges 그 이유는 OP가 모든 텍스트 상자를 참조하는'$ ("[componentname * = 'tbMoveInDate']")'를 사용하고 있기 때문입니다. 그러나 현재 범위의 요소를 참조하는'this' 키워드를 사용하고 있습니다. 전체 컬렉션이 아닙니다. –

0

string residentId = (new GUID()).ToString(); 
    string houseId = (new GUID()).ToString(); 

    HtmlTableRow detailRow = new HtmlTableRow(); 
    detailRow.Attributes.Add("residentId", residentId); 
    detailRow.Attributes.Add("houseId", houseId); 

    HtmlTableCell dataCell = new HtmlTableCell(); 

    TextBox tb = new TextBox(); 
    tb.Attributes.Add("componentname", "tbMoveInDate"); 

    tb.Attributes.Add("onchange", "updateMoveInDate(this)"; 

    cell.Controls.Add(tb); 
    detailRow.Cells.Add(dataCell); 

jQuery를 뒤에 코드에서이

tb.Attributes.Add("onchange", "updateMoveInDate(this)"; 

을 시도해보십시오

function updateMoveInDate(args) { 
    var MoveInDateEle = $(args).closest('tr'); 

}