I am new to c# and I am using windows forms.
I am trying to login into a website (https://www.followmee.com) using C# application with webBrowser control but I faced a problem when I logged in.
As shown in the code, when I click button_Login it logs in fine but as soon as it logs in it throws an error "object reference not set to an instance of an object"
This is all the code I use:
string userName= "abcd";
string LPassword = "1234";
private void button_Login_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("https://www.followmee.com/login.aspx");
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser1.Document.GetElementById("ctl00_Main_Login1_UserName").SetAttribute("value", userName);
webBrowser1.Document.GetElementById("ctl00_Main_Login1_Password").SetAttribute("value", LPassword);
webBrowser1.Document.GetElementById("ctl00_Main_Login1_LoginButton").InvokeMember("click");
}
Anyone knows what I am doing wrong or what code I am missing. Please help me , Thank you.
Someone marked my question as duplicated but I don't think so. I have already read that question and it did not help. ok it explains "You are trying to use something that is null" and I know that I am using the object that contains the null value reference but I do not know which object and what causes this.