本文介绍了在隐藏字段内动态创建html表。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i使用以下代码创建了一个html表格。



  var  sString =  ; 
sString + = < table cellpadding ='4'cellspacing ='0'class ='tableGgrid_' style ='text-align:center; width:100%;'>;
sString + = < tr class ='HeaderCell'>;
sString + = < td style ='border-width:1px; width:5%; border - 正确的风格:坚固;;
sString + = border-bottom-style:solid; border-color:#4B6C9E;' ALIGN = '左' >中;
sString + = > no ;
sString + =
< / td > ;
sString + =
< td style = ' 已删除:指针; border-width:1px;宽度:19%; border-right-style:solid;;
sString + =border-bottom-style:solid; border-color:#4B6C9E;'
align = ' left'> ;
sString + =
>员工姓名;
sString + = < / td>;
sString + = < td style ='removed:pointer; border-width:1px; width: 14%; border-right-style:solid;;
sString + = border-bottom-style:solid; border-color:#4B6C9E;' ALIGN = '左' >中;
sString + = >员工ID ;
sString + =
< / tr > ;
for(i = 0; i< oTable.Rows.length; i ++)
{

sString + =
< tr class = ' + sClass +'> ;
sString + =
< td style = ' border-width:1px; border-right-style:solid;;
sString + =border-bottom-style:solid; border-color:#4B6C9E;'
align = ' left'> ;
sString + =
< span class = ' wordwrap'> + i + < / span > ;
sString + =
< / td > ;
sString + =
< td style = ' border-width:1px; border-right-style:solid;;
sString + =border-bottom-style:solid; border-color:#4B6C9E;'
align = ' left'> ;
sString + =
< span class = ' wordwrap'> + trimAll(oTable.Rows [i] .empName.replace(/ \\ / gi,'\\'))+ < / span > ;
sString + =
< / td > ;
sString + =
< td style = ' border-width:1px; border-right-style:solid;;
sString + =border-bottom-style:solid; border-color:#4B6C9E;'
align = ' left'> ;
sString + =
< span class = ' linkText'> + trimAll(oTable.Rows [i] .cmpId)+ < / span > ;
sString + =
< / td > ;
sString + =
< / tr &g t; ;


}

sString + =
< / > ;
document.getElementById(
divAllReports )。innerHTML = sString;
document.getElementById(
ctl00_SgMainContect_hidTable )。value = sString;





然后我将sString值存储在隐藏字段中,以便在服务器端使用它。但是收到错误: -



从客户端检测到一个潜在危险的Request.Form值(ctl00 $ SgMainContect $ hidTable =

解决方案




Hi,

i created a html table using the code as below.

var sString = "";
    sString += "<table cellpadding='4' cellspacing='0' class='tableGgrid_' style='text-align: center;width: 100%;'>";
    sString += "<tr class='HeaderCell'>";
    sString += "<td style='border-width: 1px; width:5%; border-right-style: solid;";
    sString += "border-bottom-style: solid; border-color: #4B6C9E;' align='left'>";
    sString += "">no";
    sString += "</td>";
    sString += "<td style='removed: pointer; border-width: 1px; width: 19%; border-right-style: solid;";
    sString += "border-bottom-style: solid; border-color: #4B6C9E;' align='left'>";
    sString += "">Employee Name";
    sString += "</td>";
    sString += "<td style=' removed: pointer; border-width: 1px; width: 14%; border-right-style: solid;";
    sString += "border-bottom-style: solid; border-color: #4B6C9E;' align='left'>";
    sString += "">Employee ID";
    sString += "</tr>";
    for(i=0;i<oTable.Rows.length;i++)
    {

            sString += "<tr  class='" + sClass + "' >";
            sString += "<td style='border-width: 1px;  border-right-style: solid;";
            sString += "border-bottom-style: solid; border-color: #4B6C9E;' align='left'>";
            sString += "<span class='wordwrap'>" +i + "</span>";
            sString += "</td>";
            sString += "<td style='border-width: 1px;  border-right-style: solid;";
            sString += "border-bottom-style: solid; border-color: #4B6C9E;' align='left'>";
            sString += "<span class='wordwrap'>" + trimAll(oTable.Rows[i].empName.replace(/\\/gi, '\\')) + "</span>";
            sString += "</td>";
            sString += "<td style='border-width: 1px;  border-right-style: solid;";
            sString += "border-bottom-style: solid; border-color: #4B6C9E;' align='left'>";
            sString += "<span class='linkText'>" + trimAll(oTable.Rows[i].cmpId) + "</span>";
            sString += "</td>";
            sString += "</tr>";


    }

   sString += "</table>";
document.getElementById("divAllReports").innerHTML = sString;
document.getElementById("ctl00_SgMainContect_hidTable").value = sString;



then i store the sString value in a hidden field for use it in server side. but getting error:-

A potentially dangerous Request.Form value was detected from the client (ctl00$SgMainContect$hidTable="

解决方案




这篇关于在隐藏字段内动态创建html表。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 18:18