Javascript asp.net提交表单后如何获取post数据
我的asp.net中有以下表单:Javascript asp.net提交表单后如何获取post数据,javascript,c#,jquery,asp.net,forms,Javascript,C#,Jquery,Asp.net,Forms,我的asp.net中有以下表单: <html> <head> <script type="text/javascript"> function GetSampleModel() { try { var wldscan = new ActiveXObject("WebLogonDemoClient.WLDScan");
<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>
提交表单后,我尝试通过以下代码在另一个页面中获取提交的数据:
sl = Request.Form["Sl"];
String SampleModel = Request.Form["SampleModel"];
但这两个变量中没有数据。我在哪里犯错?请帮帮我
NameValueCollection nvclc = Request.Form;
调试后,我看到变量的值如下所示:
http://localhost/finger/famverifyTX.aspx?name=18&appuser='RANA001'&ailogid='1'&depamount=50&sessid='28902343093145'&custno='18'
{__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>");
}
因此,SampleModel和Sl的值为零。如何从fmaVerifyTX.aspx页面获取此值?请帮帮我 以下代码适用于我:
NameValueCollection nvclc = Request.Form;
document.getElementById("Sl").setAttribute('value', Sl_No);
document.getElementById("SampleModel").setAttribute('value', sampleModel);