html - vb.net Object reference not set to an instance of an object error when clicking a button on a webbrowser -
im trying click button in webbrowser.
i have created button in form click button, gives me error on line
dim elements htmlelementcollection = custombrowser.document.all
could website blocking me clicking button?? here custom browser class:
public class custombrowser inherits webbrowser public sub new() me.scripterrorssuppressed = true end sub private sub docomplited() handles me.documentcompleted dim tp tabpage = me.tag my.settings.ddd = tp.text if me.documenttitle.length > 15 tp.text = me.documenttitle.substring(0, 14) & "" else tp.text = me.documenttitle end if my.settings.ddd = tp.text end sub private sub custombrowser_locationchanged(byval sender object, byval e system.eventargs) handles me.locationchanged end sub private sub custombrowser_navigated(byval sender object, byval e system.windows.forms.webbrowsernavigatedeventargs) handles me.navigated form1.label1.text = me.url.tostring end sub end class
the buttton code :
private sub button2_click(byval sender system.object, byval e system.eventargs) handles button2.click if custombrowser.document isnot nothing dim elements htmlelementcollection = custombrowser.document.all each webpageelement htmlelement in elements custombrowser.document.all("click").invokemember("click") if webpageelement.getattribute("class") = "click" webpageelement.invokemember("click") end if next end if end sub
Comments
Post a Comment