I am trying to set a value in a field of type Textarea using webbrowser, but the value is not being set.
I've tried the following ways;
webBrowser.Document.GetElementsByTagName("p")[2].InnerHtml = texto;
webBrowser.Document.GetElementsByTagName("p")[2].InnerText = texto;
webBrowser.Document.GetElementsByTagName("p")[2].SetAttribute("value", texto);
None worked.
No html is like this.
<div class="panel-body">
<label for="formGroupExampleInput">Coloque o texto acima no Textarea abaixo:</label>
<p><textarea class="form-control" rows="7"> </textarea></p>
<p> </p>
<p style="text-align:right;">
<input type="submit" id="Submit" name="Submit" value="Próxima Tarefa" class="btn btn-primary" onclick="nextStep();">
</p>
</div>
It's no.
<p><textarea class="form-control" rows="7"> </textarea></p>
That the text should be set.
public void Stap3()
{
HtmlDocument doc = webBrowser.Document;
if (load)
{
load = false;
webBrowser.Navigate("http://indigo.rafson.com.br/02.php");
while (webBrowser.ReadyState != WebBrowserReadyState.Complete && webBrowser.Document == null)
{
Application.DoEvents();
}
doc = webBrowser.Document.Window.Open("http://indigo.rafson.com.br/02.php", "", "", false).Document;
}
int x = 0;
while (x == 0)
{
Application.DoEvents();
if (doc.GetElementsByTagName("p") != null &&
doc.GetElementById("submit") != null)
break;
}
String texto = string.Empty;
foreach (HtmlWindow frame in doc.Window.Frames)
{
texto = frame.Document.GetElementsByTagName("p")[0].InnerHtml;
texto += ";" + frame.Document.GetElementsByTagName("cite")[0].InnerHtml;
}
if (!string.IsNullOrEmpty(texto))
{
webBrowser.Document.GetElementsByTagName("p")[2].SetAttribute("value", texto);
HtmlElement submit = doc.GetElementById("submit");
submit.InvokeMember("click");
NextStap = Stap4;
}
else
{
NextStap = Stap3;
}
}
The complete solution is here .