使用Java脚本删除asp:Table行(已解决) [英] Remove asp:Table row using Javascript (Solved)
本文介绍了使用Java脚本删除asp:Table行(已解决)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的所有人,我在aspx页面中有ASP:Table,我正尝试使用ajax在客户端删除行(删除行),我在每行的表内单元格中都有按钮,我在onclick事件中调用了以下代码按钮的按钮,但它确实起作用,下面的代码仅适用于HTML表.
Dear All, I have ASP:Table in my aspx page which I am trying delete rows (remove rows) in client side using ajax, I have button in a cell inside the table in each row I call bellow code in onclick event of the button but it doesent work, well bellow code works with HTML table only.
function deleteSegmentRow(src) {
var tb = '<%=this.tbSubM16.ClientID %>';
var oRow = src.parentElement.parentElement;
if (oRow.id != null) {
tb.deleteRow(oRow.rowIndex);
var rowCount = tb.rows.length;
if (rowCount == 1) {
tb.deleteRow(0); //Remove Title
}
}
return false;
}
在后端分配onclick事件的代码
code for assigning onclick event in backend
btn.Attributes.Add("onclick", "return deleteSegmentRow(this);");
贝娄声明在到达声明时确实起作用
the statement bellow doesent work as it reachs the statement
tb.deleteRow(oRow.rowIndex);
我确实用下面的代码解决了这个问题
I do solved the issue with bellow Code
function deleteSegmentRow(src) {
var tb = document.getElementById('<%=this.tbSubM16.ClientID %>'); //Changed Only This Line
var oRow = src.parentElement.parentElement;
if (oRow.id != null) {
if (oRow.tagName=='TR')//Only For Checking if its Row Only{
tb.deleteRow(oRow.rowIndex);
var rowCount = tb.rows.length;
if (rowCount == 1) {
tb.deleteRow(0); //Remove Title
}
}
//setTotalGrossAmount();
}
return false;
}
推荐答案
已解决仅从未答复列表中删除:由OP解决.
Answered only to remove from Unanswered list: solved by the OP.
这篇关于使用Java脚本删除asp:Table行(已解决)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文