如何填写as​​p页面并调用提交按钮并查看结果页面

时间:2013-10-22 07:20:43

标签: c# asp.net .net

我是webclient流程的新手。 这是我想从我的Web应用程序登录的asp页面: -

http://localhost/alis/services.asp

<TABLE width="1261">
  <FORM action="sign_handler_control_id.asp" onsubmit="return LoginForm_Validation(this)" name="TheForm" method="post" >

  <TBODY>
   <TR>
  <TH width="700" valign="middle" align="left"><FONT color="#000000"><U><FONT color="#000000" face="Arial" size="+1">Pengguna yang telah mendaftar, sila masukkan Kod Agensi, ID Pengguna dan Katalaluan</FONT></U><FONT color="#000000" face="Georgia" size="-1">.</FONT></FONT><FONT size="+1" color="#000000"><U><FONT face=Tahoma 
size=-1 color="#000000"><BR>
  </FONT></U></FONT><FONT size="+1"><FONT face="Tahoma" size="-1"><BR>
    <BR>
     </FONT></FONT>
    <TABLE width="1261" cellspacing="1" cellpadding="1" height="56" style="height: 31px; left: 10px; top: 326px">
   <TBODY>
      <TR>
        <TD width="126"><FONT face="Arial" size="+0"><B>Kod Agensi</B></FONT></TD>
        <TD width="300" colspan="2">
        <INPUT size="3" tabindex="1" type="text" name="agcy_id"  maxlength="3" onFocus="nextfield='agcy_id1';">&nbsp;
        <INPUT size="5" tabindex="1" type="text" name="agcy_id1"  maxlength="5" onblur="jump(this)" onFocus="nextfield='user_id';">&nbsp;
        </TD>
      </TR>
      <TR>
        <TD width="126"></TD>
       <TD width="300" colspan="2"><INPUT size="95" tabindex="1" type="text" name="agcy_desc" maxlength="150" onblur="fc()" disabled></TD>
      </TR>
      <TR>
        <TD width="126"><FONT face="Arial" size="+0"><B>ID Pengguna</B></FONT></TD>
        <TD width="300" colspan="2"><INPUT size="20" type="text" name="user_id" tabindex="2" maxlength="8" onFocus="nextfield='new_pwd';"></TD>
      </TR>
      <TR>
        <TD width="126"><FONT face="Arial" size="+0"><B>Katalaluan</B></FONT></TD>
        <TD width="300" colspan="2">
        <INPUT size="20" type="password" name="new_pwd" tabindex="3" maxlength="8" onFocus="nextfield='SubmitLogin';">
        &nbsp;&nbsp;&nbsp;<script src="accept.asp"><INPUT size="1" type="hidden" name="acceptvalue" value="1"></script>
        </TD>
      </TR>
    </TBODY>

  <td width="126">

  <BR>

  <td width="300" colspan="2">

  <TR>
  <TD width="126">
    <p align="left"></TD>

  <TD width="145">
    <p align="right"><INPUT type="submit"  id="SubmitLogin" name="SubmitLogin" value="Login" tabindex="4"></TD>

我需要填写5个字段并调用“登录”按钮。 agcy_id 2. agcy_id1 3. agcy_desc 4. user_id 5. new_pwd

如何使用asp.net C#自动登录?任何人都知道如何启动它?感谢您的回复。

1 个答案:

答案 0 :(得分:0)

使用Jquery执行POST请求 - ajax传递表单数据参数 例如:

var formData = {agcy_id :"val",agcy_id1 :"val2",agcy_desc :"val3", agcy_desc:"val4"}; 

$.ajax({
    url : "YOUR_POST_URL",
    type: "POST",
    data : formData,
    success: function(data, textStatus, jqXHR)
    {
        //data - response from server
    },
    error: function (jqXHR, textStatus, errorThrown)
    {

    }
});

这里有AJAX调用的实时示例,以及接收参数的服务器的答案:

Jquery AJAX POST Example

执行AJAX POST后,您可以检索代码隐藏中的参数:

NameValueCollection nvc = Request.Form;
string agcy_id_var;
if (!string.IsNullOrEmpty(nvc["agcy_id "]))
{
  agcy_id_var= nvc["agcy_id "];
}