为什么我不能将属性设置为此元素?

时间:2017-08-13 16:13:19

标签: c# html dotnetbrowser

我试图使用dotnetbrowser填充文本框,

这是元素来源,

<input class="p-input__ctrl" placeholder="Amount" onchange="changeAmount('Form', this.value, {&quot;NT&quot;:0}, {&quot;4737057&quot;:{&quot;currency&quot;:&quot;EUR&quot;,&quot;platform&quot;:&quot;mt4_real&quot;,&quot;a_id&quot;:4737057,&quot;type&quot;:&quot;cent&quot;,&quot;reg_date&quot;:&quot;07.08.2017&quot;,&quot;balance&quot;:0,&quot;currency_symbol&quot;:&quot;\u20ac&amp;thinsp;&quot;,&quot;server_account_number&quot;:800086,&quot;show_express_field&quot;:false,&quot;has_bonus_60&quot;:false,&quot;fix_rate&quot;:false,&quot;exchangeRate&quot;:{&quot;NT&quot;:{&quot;USD&quot;:0.85,&quot;EUR&quot;:1}},&quot;exchangeRateBack&quot;:{&quot;NT&quot;:{&quot;USD&quot;:1.1765,&quot;EUR&quot;:1}}}}, {&quot;NT&quot;:{&quot;exchangeRate&quot;:[]}}, {&quot;NT&quot;:null}, 'taking into account the payment system commission= ');" name="amount" id="Form_amount" type="text" maxlength="12">

我的代码是:

DOMDocument Doc = Browser.GetDocument();
Doc.GetElementById("Form_amount").SetAttribute("value", "1");

没有任何反应,它不会在输入中添加1。

1 个答案:

答案 0 :(得分:2)

你可以尝试这段代码:

DOMDocument Doc = Browser.GetDocument();    
DOMInputElement txtAmt = (DOMInputElement)Doc.GetElementByName("amount");
txtAmt.Value = "John";

来源:dotnetbrowser docs