2

I am using HtmlAgilityPack and it seems I cannot set the value of the text in a textarea in the same way as an input field:

var node = doc.DocumentNode.SelectSingleNode("//textarea");
if (node != null)
{
    node.SetAttributeValue("value", record.Data);
}

Does anyone know how this can be done?

Amit
  • 45,440
  • 9
  • 78
  • 110
realtek
  • 831
  • 4
  • 16
  • 36

1 Answers1

2

A <textarea> element doesn't have a value attribute. It's content is it's own text node:

<textarea>
Some content
</textarea>

To access that, use the .InnerHtml property:

var node = doc.DocumentNode.SelectSingleNode("//textarea");
if (node != null)
{
    node.InnerHtml = record.Data;
}
Amit
  • 45,440
  • 9
  • 78
  • 110