Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 向网站上的密码字段发送/设置值_C#_Html_Vb.net_Passwords - Fatal编程技术网

C# 向网站上的密码字段发送/设置值

C# 向网站上的密码字段发送/设置值,c#,html,vb.net,passwords,C#,Html,Vb.net,Passwords,我写了一个小应用程序,需要登录到一个网站来执行一些操作。 问题是,每当我试图在网站上设置密码字段时,它都不接受密码 我已经通过使用SendKeys函数找到了解决这个问题的方法。问题是它需要焦点,程序需要在后台运行 有办法做到这一点吗 下面是如何设置用户名字段的示例: WebBrowser.Document.GetElementById("field-username").SetAttribute("value", "UserName") 任何帮助都会很好。尝试使用或此问题的答案如下: WebB

我写了一个小应用程序,需要登录到一个网站来执行一些操作。 问题是,每当我试图在网站上设置密码字段时,它都不接受密码

我已经通过使用SendKeys函数找到了解决这个问题的方法。问题是它需要焦点,程序需要在后台运行

有办法做到这一点吗

下面是如何设置用户名字段的示例:

WebBrowser.Document.GetElementById("field-username").SetAttribute("value", "UserName")

任何帮助都会很好。

尝试使用或

此问题的答案如下:

WebBrowser.Document.GetElementById("field-loginFormPassword").SetAttribute("maxLength", "20")
WebBrowser.Document.GetElementById("field-loginFormPassword").SetAttribute("value", "yourpassword")

通过更改“maxlength”值,您可以将“value”设置为所需的文本,然后您可以提交表单,表单将接受它。

什么是webBackground?这是一个普通的html页面?它是WebBrowser组件。该站点是否使用Javascript使用其keydown/up/press事件对密码字段进行处理?使用Fiddler调试表单字段,查看发送的内容。运行Fiddler,我没有看到按键/向上/向下事件…谢谢大家,我找到了如何执行的答案。让我度过了一天中最好的时光。如果你知道要寻找什么,这相对容易:)谢谢大家的建议:)请发布你的解决方案,我也遇到了这个问题@XantorAmnobius