简体   繁体   English

使用ASP.Net C#网页自动填充网页

[英]Auto fill web page using ASP.Net C# web page

I need to write a ASP.Net C# web page that can open a web page, fill in the fields and click the submit button on the web page automatically. 我需要编写一个可以打开网页的ASP.Net C#网页,填写字段并自动单击网页上的“提交”按钮。 My web page should launch the IE browser and navigate to a specified URL and fill the form and submit it. 我的网页应启动IE浏览器并导航到指定的URL,然后填写表格并提交。 Not sure where I should start from. 不知道我应该从哪里开始。 Any help is greatly appreciated. 任何帮助是极大的赞赏。

Thank you. 谢谢。

I'm not sure that, browser will allow to run all your js code. 我不确定,浏览器是否允许运行您的所有js代码。 But you can try with jquery, or with some another javascript lib. 但是您可以尝试使用jquery或其他javascript库。

You can add to your page iframe tag, than add dynamically another web-site to the iframe content. 您可以将iframe标记添加到页面中,而不是将另一个网站动态添加到iframe内容中。 You also must know id's or classNames of html controls. 您还必须知道HTML控件的ID或类名。

if you're going to use jquery 如果您要使用jQuery

 $(document).ready(function () {
        $('#textbox1').val()="someText1";
        ....
        $('#textboxN').val()="someTextN";


        //call click event
        $('#btnID').click();

 });

to automatically start your page, you can use Process.Start() method in server side. 要自动启动页面,可以在服务器端使用Process.Start()方法 if you're trying too run in client side, you can use Response.Redirect Method 如果您也尝试在客户端运行,则可以使用Response.Redirect方法

Why not make a POST/GET call directly? 为什么不直接拨打POST / GET电话?

You could use HTTPWebRequest http://www.codeproject.com/KB/webservices/HttpWebRequest_Response.aspx 您可以使用HTTPWebRequest http://www.codeproject.com/KB/webservices/HttpWebRequest_Response.aspx

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

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