c# - 如何用C#读取TD的值?

标签 c# javascript html internet-explorer bho

这是我们的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/

相关文章:

c# - 清除文本文件中过多旧数据的高效方法

javascript - 使用 Angularjs 中的指令创建 ajax 加载微调器

c# - 时区策略

Javascript 正则表达式 空格替换

HTML 2 列布局 - 将背景颜色应用于顶层容器

c# - C# 中是否有类似 Java 的 throws 关键字?

c# - 如何设置现有的 Explorer.exe 实例来选择文件?

html - 使容器 div 用粘性页脚填充所有布局

c# - WPF 可扩展 StackPanel(或其他东西)

html - html 标题标签(<h1>、<h2>、<h3> 等)的默认字体大小(以像素为单位)是多少?