标签:style blog http io color ar os java sp
原文:JavaScript后台代码操作HTML TABLE的方法var rowNum = 0,fileNum = 0; //行号与列号
var oNewRow; //定义插入行对象
var oNewCell1,oNewCell2; //定义插入列对象
var fileNum = 1;
function addFileToTable(strFile)
{
fileNum +=1;
rowNum = document.getElementById("NewFileList").rows.length;
oNewRow = document.getElementById("NewFileList").insertRow(rowNum);
oNewRow.id = "clientRow_" + fileNum;
//添加第一列
oNewCell1 = document.getElementById("NewFileList").rows[rowNum].insertCell(0);
oNewCell1.innerHTML = "<input type=‘Text‘ readonly=‘readonly‘ style=‘border:0px;width:100px;‘ value=‘" + getFileName(strFile) + "‘ />";
//添加第二列
oNewCell2 = document.getElementById("NewFileList").rows[rowNum].insertCell(1);
oNewCell2.innerHTML =" <span name=" + fileNum + " style=‘cursor:hand;color:Red; text-decoration:none; font-family:@HGP?????E;‘ onClick=‘DelClientRow(this);‘ >X</span>";
}
ASP.NET后台代码操作HTML TABLE的方法
例1:该方法是读取服务器上路经为"strFilePath"的文件夹中的所有文件,并显示在页面上ID为"OldFileList"的TABLE中,注意,这个TABLE的"runat=server"。
public void ShowFilesIn(string strFilePath)
{
OldFileList.Rows.Clear();
string[] strFileNames = GetFilesInServer(strFilePath);
for (int i = 0; i < strFileNames.Length; i++)
{
HtmlTableRow newRow = new HtmlTableRow();
newRow.ID = "serverRow_" + i;
HtmlTableCell cell1 = new HtmlTableCell();
HtmlTableCell cell2 = new HtmlTableCell();
cell1.InnerHtml = "<input type=‘Text‘ readonly=‘readonly‘ style=‘border:0px;width:90px;‘ value=‘" + strFileNames[i] + "‘ />";
cell2.InnerHtml = " <span name=" + strFileNames[i] + " style=‘cursor:hand;color:Red; text-decoration:none; font-family:@HGP?????E;‘ onClick=‘DelServerRow(this);‘ >X</span>";
newRow.Cells.Add(cell1);
newRow.Cells.Add(cell2);
OldFileList.Rows.Add(newRow);
}
}
标签:style blog http io color ar os java sp
原文地址:http://www.cnblogs.com/lonelyxmas/p/4084983.html