现在的位置: 首页 > 综合 > 正文

客户端改变状态,服务器服务器端读不到数据的问题,大家有什么好的解决方法.

2013年06月14日 ⁄ 综合 ⁄ 共 586字 ⁄ 字号 评论关闭
比如:一个DropDownList我采用我无刷新模式,在客户端通过JS来实现,最后通过点击保存来改新数据。

但你在服务端,数据还是原来的数据,没有办法直接读数据。

因为数据是保存在ViewState里的,在客户端修改了内容,ViewSate没有修改。所以到服务器还是读旧数据。

一个解决方法。用<input type=hidden id="hd_value" runat="server"/>Hidden在客户端改变数据能在服务器端读到改改的数据。

这样,我们就可以在提交之前后当前DropDownList编码到上面的Hidden

<form id="Form1" method="post" runat="server" onsubmit="selectall()">
function selectall()

{

        o_col 
= document.all("ddl_Center");

        str 
= "";

        
for(i = 0 ;i< o_col.length;i++)

        {

            str 
+= o_col.options[i].value + ",";

        }

        document.all(
"hd_Center").value = str;

        

        

}

这样就能分析数据了。

抱歉!评论已关闭.