我在我的一个asp.net中有以下表格:
<html>
<head>
<script type="text/javascript">
function GetSampleModel() {
try {
var wldscan = new ActiveXObject("WebLogonDemoClient.WLDScan");
var Sl_No = wldscan.GetSl();
var sampleModel = wldscan.GetVerifyTemplate();
if (sampleModel.length == 0) {
alert("Something is Error!!!", "Error");
}
else {
document.getElementById("scan").Sl.Value = Sl_No;
document.getElementById("scan").SampleModel.Value = sampleModel;
document.getElementById("scan").submit();
}
}
catch (err) {
alert("To verify with a fingerprint device, you should install the WebLogonDemoClient software first.", "Software Not Install Error");
}
}
</script>
<title>Logon</title>
</head>
<body onload="GetSampleModel()">
<form name="scan" id="scan" method="Post" action="" runat="server">
<input type="Hidden" name="SampleModel" value="">
<input type="Hidden" name="Sl" value="">
</form>
</body>
</html>
此表格的行动如下:
http://localhost/finger/famverifyTX.aspx?name=18&appuser='RANA001'&ailogid='1'&depamount=50&sessid='28902343093145'&custno='18'
表单提交后,我试图通过以下代码在另一个页面中提交数据:
sl = Request.Form["Sl"];
String SampleModel = Request.Form["SampleModel"];
但这两个变量中没有数据。我在哪里做错了?请帮我 。
NameValueCollection nvclc = Request.Form;
在debuggin之后,我看到变量的值如下:
{__VIEWSTATE=%2fwEPDwUKLTE4MDU5MzAwNg9kFgICAw8WAh4GYWN0aW9uBUNmYW12ZXJpZnlUWC5hc3B4P25hbWU9JmFwcHVzZXI9JmFpbG9naWQ9JmRlcGFtb3VudD0mc2Vzc2lkPSZjdXN0bm89ZGRLaLIbf6gMRB5SeuUkSj7FHaf%2fRZQuSXp1AE1b4qHvCw%3d%3d&SampleModel=&Sl=&__VIEWSTATEGENERATOR=9EF55AFD}
我有这段代码:
string[] keys = Request.Form.AllKeys;
var value = "";
for (int i = 0; i < keys.Length; i++)
{
// here you get the name eg test[0].quantity
// keys[i];
// to get the value you use
value = Request.Form[keys[i]];
Response.Write("Keys is " + keys[i] + " and value is " + value+"<br>");
}
此代码显示此输出:
Keys is SampleModel and value is
Keys is Sl and value is
所以SampleModel和Sl的值都没有。如何从fmaVerifyTX.aspx页面获取此值?请帮我 。
答案 0 :(得分:3)
以下代码适用于我:
document.getElementById("Sl").setAttribute('value', Sl_No);
document.getElementById("SampleModel").setAttribute('value', sampleModel);