Quantcast
Channel: CSharp Forum Latest Questions
Viewing all articles
Browse latest Browse all 32056

Why the OuterHTML feature leads to an Error

$
0
0

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:

publicvoidSetDefaultValue(stringControlID,stringValue){HtmlDocument doc = webBrowser1.Document;HtmlElementlist= doc.GetElementById(ControlID);list.OuterHtml =Value;}privatevoidForm1_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.


Viewing all articles
Browse latest Browse all 32056

Trending Articles