在外部JavaScript文件中查找用户控件的客户端ID

时间:2018-05-11 21:47:28

标签: javascript jquery asp.net user-controls infragistics

在我的asp.net应用程序中,在父页面(.aspx)下呈现了几个用户控件(.ascx)。在每个用户控件中,我调用javascript函数和一些其他Infragistics客户端事件(它只能接受某些参数)。这些函数是在外部javascript文件中编写的,并包含在父页面中。

问题是当我在每个函数中使用$ find("<%= Me.grdDataTable.ClientID%>")来查找来自调用来源的用户控件时,它返回为null。我无法更改传递给某些JS方法的参数,因为它们与仅接受特定参数的Infragistics事件有关。

有没有办法在不向JS方法引入输入参数的情况下从调用JavaScript方法的位置找到用户控件的客户端ID?

我使用的一些JS方法:

function WebDataGridControl_AddRow() {    
    // Commit the row that was added to ROWADDING server event
    $find("<%= Me.grdDataTable.ClientID%>")
     .get_behaviors()
     .get_editingCore()
     .get_behaviors().get_rowAdding()._commitRow();
}
function WebDataGridControl_RowSelection_Changed(webDataGrid, evntArgs) {
    // When row is changed, get the index of the row selected
    var grid = $find("<%= Me.grdDataTable.ClientID%>");
    var gridBehaviors = grid.get_behaviors();
    var row = gridBehaviors.get_selection().get_selectedRows().getItem(0);
    $('#<%=hdnEditRow.ClientID%>').val(row.get_index());
}

谢谢, AV

0 个答案:

没有答案