I have been trying to change the HTML code of a select tag in an HTML code but whenever I do that the
"Object reference not set to an instance of an object"
error occurs.This is the C# code:
public void SetDefaultValue(string ControlID,string Value)
{
HtmlDocument doc = webBrowser1.Document;
HtmlElement list = doc.GetElementById(ControlID);
list.OuterHtml = Value;
}
private void Form1_Load(object sender, EventArgs e)
{
htmlLoadWebbrowser1.SetDefaultValue("D8876943-5861-4D62-9249-C5FEF88219FA", "<SELECT id=\"D8876943-5861-4D62-9249-C5FEF88219FA\" multiple size=\"4\" name=\"drop1\"> <OPTION value=\"3\">item 3</OPTION></SELECT>");
}
The function is supposed to change the inner code of an HTML page,it receives the ID of the control by "controlID
" and generates the inner code by "Value".
I suspect that I need to call it elsewhere,the problem is I do not know where
Thank you.