这是我们的CMIS(计算机管理信息系统)服务器页面:(注:CMIS服务器我无法修改,该页面是自动生成的。)
<form method="POST" action="bl_view_invoice_controler.jsp" name="fm1" onSubmit="return checkValid()">
//please attention the form name is 'fm1'
<TABLE id=AutoNumber7 style="BORDER-COLLAPSE: collapse"
borderColor=#111111 cellSpacing=0 cellPadding=2 width="100%"
border=0>
<TBODY>
<TR>
<TD width="40%"><input type="text" class="underline1" name="ivcd_item" size="15"></TD>
<TD width="20%"><input type="text" class="underline1" name="ivcd_unitprice" size="8"></TD>
<TD width="20%"><input type="text" class="underline1" name="ivcd_quantity" size="8"></TD>
<TD width="20%"><input type="text" class="underline1" name="ivcd_totalfc" size="8"></TD>
<TD width="40%"><input type="text" class="underline1" name="ivcd_item" size="15"></TD>
<TD width="20%"><input type="text" class="underline1" name="ivcd_unitprice" size="8"></TD>
<TD width="20%"><input type="text" class="underline1" name="ivcd_quantity" size="8"></TD>
<TD width="20%"><input type="text" class="underline1" name="ivcd_totalfc" size="8"></TD>
</TR>
<TR>
<TD width="40%"><input type="text" class="underline1" name="ivcd_item" size="15"></TD>
<TD width="20%"><input type="text" class="underline1" name="ivcd_unitprice" size="8"></TD>
<TD width="20%"><input type="text" class="underline1" name="ivcd_quantity" size="8"></TD>
<TD width="20%"><input type="text" class="underline1" name="ivcd_totalfc" size="8"></TD>
<TD width="40%"><input type="text" class="underline1" name="ivcd_item" size="15"></TD>
<TD width="20%"><input type="text" class="underline1" name="ivcd_unitprice" size="8"></TD>
<TD width="20%"><input type="text" class="underline1" name="ivcd_quantity" size="8"></TD>
<TD width="20%"><input type="text" class="underline1" name="ivcd_totalfc" size="8"></TD>
</TR>
</TBODY>
</TABLE>
<script language="JavaScript"> //this script store the value of the table
fm1.ivcd_item['0'].value="B747-400";
fm1.ivcd_totalfc['0'].value="500.00";
fm1.ivcd_unitprice['0'].value="1";
fm1.ivcd_quantity['0'].value="";
fm1.ivcd_item['2'].value="B747-800";
fm1.ivcd_totalfc['2'].value="250.00";
fm1.ivcd_unitprice['2'].value="";
fm1.ivcd_quantity['2'].value="";
</script>
</FORM>
我的问题是,如何使用C#获取表的值,例如“B747-400”或“B747-800”?
最佳答案
我认为你可以这样做..
1、放置隐藏文本,如
<input type="hidden" id="tableInfo" runat="server" />
2、放一个按钮,比如
<input type = "button" id = "btnSample" onclick = "getTableInfo();" />
3、通过javascript实现你的getTableInfo函数,如
function getTableInfo()
{
var tb=$("tableName");
var data=[];
for(var i=1;i<tb.rows.length;i++) {
data.push(tb.rows[i].cells[0].firstChild.value);
data.push(tb.rows[i].cells[1].firstChild.value);
data.push(tb.rows[i].cells[2].firstChild.value);
}
$("tableInfo").value=data.join("`");
__doPostBack("Button1" , ""); // Call you server side function here
}
4、然后在你的Button1的服务器端函数中,你可以从隐藏的文本框中获取tableinfo
关于c# - 如何用C#读取TD的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9937466/