当前位置: 代码迷 >> ASP.NET >> 遍历Request.Form取植,该如何处理
  详细解决方案

遍历Request.Form取植,该如何处理

热度:589   发布时间:2013-02-26 00:00:00.0
遍历Request.Form取植
用遍历Request.Form的方法获取页面中web控件的值,如下
this.Label2.Text   =   Request.Form.Count.ToString();
string   xs   =   " ";
for   (int   i   =   0;   i   <   Request.Form.Count;   i++)
{
            this.Label2.Text=this.Label2.Text+ "|| "+Request.Form[i].Trim();
            xs   =   this.Label2.Text;
}

共有8个控件,但实际遍历却是13个值,且要么为空,要么是很长的乱码,如下(用‘||’隔开):  
13||||||||/wEPDwUKLTc5MTMyODAyMg9kFgICAw9kFgoCBQ8QZBAVBAcyMDA25bm0BzIwMDflubQHMjAwOOW5tAcyMDA55bm0FQQEMjAwNgQyMDA3BDIwMDgEMjAwORQrAwRnZ2dnZGQCBw8QZBAVDAQx5pyIBDLmnIgEM+aciAQ05pyIBDXmnIgENuaciAQ35pyIBDjmnIgEOeaciAUxMOaciAUxMeaciAUxMuaciBUMATEBMgEzATQBNQE2ATcBOAE5AjEwAjExAjEyFCsDDGdnZ2dnZ2dnZ2dnZ2RkAgkPEGRkFgFmZAIPDxBkEBUGD+S4jeS9v+eUqOaooeeJiC3kuJPkuJrmioDmnK/kurrlkZjorqHnrpfmnLrlupTnlKjog73lipvogIPor5UV5Zyf5Zyw566h55CG5Luj55CG5Lq6G+aKlei1hOW7uuiuvumhueebrueuoeeQhuW4iA3nvZHkuIrmiqXlkI0yHeazqOWGjOWSqOivouW3peeoi+W4iCjmipXotYQpFQYDd21iCWpzanl5MjAwNwZ0ZDIwMDcIdHp4bTIwMDcId3NibTIwMDgIenh0ejIwMDcUKwMGZ2dnZ2dnZGQCEw8PFgIeBFRleHQFuQcxM3x8fHx8fHx8L3dFUER3VUtMVGM1TVRNeU9EQXlNZzlrRmdJQ0F3OWtGZ2dDQlE4UVpCQVZCQWN5TURBMjVibTBCekl3TURmbHViUUhNakF3T09XNXRBY3lNREE1NWJtMEZRUUVNakF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nTGJwL0dFQ1FMazlKaWJDd0xSdXNUTUR3S001NHJHQmc4UXJZd3pkU05KdGJVSGV5c283c2s2TnlXMWRkZKMbiLvsLSc6tsICr95Hy73zM9/E||1||2||2008||5||Y||3||jsjyy2007||添加设定||/wEWHgL18qGWBQLqgv/4BgLjgtv4BgKlm5WbAQKlm4H2CQKlm62fDwKlm5n6BwKPh+bQCgKOh+bQCgKNh+bQCgKMh+bQCgKLh+bQCgKKh+bQCgKJh+bQCgKYh+bQCgKXh

1||2||2008||5||Y||3||jsjyy2007||添加设定   是正常的值

------解决方案--------------------------------------------------------
控件只有8个,但还有好几个隐藏域不是乱码,那个是viewsate中的值
------解决方案--------------------------------------------------------
你看看客户端的html查找input 或select元素的个数就知道了.
  相关解决方案