在IE浏览器中工作,在Firefox中,两个字段为空白,并且在分配后,名称在EditUserRoles中未定义:
从gridview调用GetRows,调用editUserRoles
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<input type="button" id="btnEditUserRoles" style="width:60px;" onclick="GetRows(this.parentNode.parentNode.rowIndex)" value="Edit" />
</ItemTemplate>
</asp:TemplateField>
<input type="text" disabled="disabled" id="txtAkoUserName" />
<input type="text" id="txtUserName" />
function GetRows(index) {
var userGrid = document.getElementById('<%=gridUserRoles.ClientID%>');
EditUserRoles(index, userGrid);
}
function EditUserRoles(rowIndex, userGrid) {
if (null != userGrid) {
var userName = userGrid.rows[rowIndex].cells[0].innerText;
var name = userGrid.rows[rowIndex].cells[1].innerText;
LoadEditForm(userName, name);
}
function LoadEditForm(userName, name) {
$("#txtAkoUserName").val(userName);
$("#txtUserName").val(name);
}
答案 0 :(得分:6)
Firefox does not support innerText
。只需使用jQuery来避免这些跨浏览器问题(这就是它的用途):
var userName = $(userGrid.rows[rowIndex].cells[0]).text();
var name = $(userGrid.rows[rowIndex].cells[1]).text();