当网页托管在WebBrowser控件中时,如何单击ASP.NET Web窗体的按钮 [英] How do I click an ASP.NET webform's button when the page is hosted in a WebBrowser Control

查看:55
本文介绍了当网页托管在WebBrowser控件中时,如何单击ASP.NET Web窗体的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网页中有一个标准的ASP.NET Web表单,并且此页面托管在带有WebBrowser控件的.NET Winform中.使用C#如何控制WebBrowser控件提交ASP.NET表单?(例如,以某种方式从Winform中单击"按钮?)

I have a standard ASP.NET web form in a web page, and this page is hosted in a .NET Winform with a WebBrowser Control. Using c# how do I control the WebBrowser Control to submit the ASP.NET form? (eg somehow "clicking" on the button from the Winform?)

更新:为了使事情复杂化,我们使用了ASP.NET验证程序,这些验证程序似乎使简单的document.forms(0).submit()无效

Update: to complicate things we have the ASP.NET validators which seem to make simple document.forms(0).submit() not work

推荐答案

由于ASP.NET验证程序的复杂性以某种方式弄乱了正常的form.submit()流,因此必须调用提交按钮的click方法:

Because of the complication of the ASP.NET validators somehow messing with the normal form.submit() flow the submit button's click method had to be called:

WebBrowser1.Document.getElementById("mybutton").InvokeMember("click");

这篇关于当网页托管在WebBrowser控件中时,如何单击ASP.NET Web窗体的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆