在webbrowser上注入javascript命令c#

时间:2014-07-06 13:12:03

标签: c# javascript inject

我想在webbrowser上注入这些命令..我怎么能这样做?

oFormObject = document.forms['formid'];  
oFormObject.elements["name"].value = 'Some Value';
document.getElementById('formid').submit();

1 个答案:

答案 0 :(得分:1)

您需要阅读ClientScriptManager.RegisterClientScriptBlock

StringBuilder csText = new StringBuilder();
      csText.Append("<script type=\"text/javascript\"> function DoClick() {");
      csText.Append("Form1.Message.value='Text from client script.'} </");
      csText.Append("script>");
      cs.RegisterClientScriptBlock(csType, csName, csText.ToString());