简体   繁体   English

asp.net提交表单后如何获取帖子数据

[英]How to get post data after form submission by asp.net

I have the following form in one of my asp.net : 我的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>

The action of this form is as following : 该表格的作用如下:

http://localhost/finger/famverifyTX.aspx?name=18&appuser='RANA001'&ailogid='1'&depamount=50&sessid='28902343093145'&custno='18'

After form submission, I am trying to get submitted data in another page by the following code : 提交表单后,我尝试通过以下代码在另一页中获取提交的数据:

sl = Request.Form["Sl"];
 String SampleModel = Request.Form["SampleModel"];

But there is no data in these 2 variables. 但是这两个变量中没有数据。 Where am I doing mistake ? 我在哪里做错了? Please help me . 请帮我 。

NameValueCollection nvclc = Request.Form;

After debuggin I am seeing the value of variable as following : 调试后,我看到的变量值如下:

{__VIEWSTATE=%2fwEPDwUKLTE4MDU5MzAwNg9kFgICAw8WAh4GYWN0aW9uBUNmYW12ZXJpZnlUWC5hc3B4P25hbWU9JmFwcHVzZXI9JmFpbG9naWQ9JmRlcGFtb3VudD0mc2Vzc2lkPSZjdXN0bm89ZGRLaLIbf6gMRB5SeuUkSj7FHaf%2fRZQuSXp1AE1b4qHvCw%3d%3d&SampleModel=&Sl=&__VIEWSTATEGENERATOR=9EF55AFD}

I have this code : 我有这个代码:

 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>");

        }

This code shows this output : 此代码显示此输出:

Keys is SampleModel and value is 
Keys is Sl and value is 

So the value of SampleModel and Sl is nothing . 所以SampleModel和Sl的值是空。 How can I get this value from fmaVerifyTX.aspx page ? 如何从fmaVerifyTX.aspx页获得此值? Please help me . 请帮我 。

The following code works for me : 以下代码对我有用:

document.getElementById("Sl").setAttribute('value', Sl_No);
document.getElementById("SampleModel").setAttribute('value', sampleModel);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM