I am still a beginner in c#. I have a console application. In javascript, we can do the following document.getElementById("myText").value = "Mary; which is used to set an HTML element. Is this possible in a console application that sending an HTTP requests to a website or should the application be using a post method. Please see code so far below. There is a textbox with the tag name testmedownelement at the website(www.~~~~~~~~~~~~~~~~~~~~~~.com).
This is the javascript code: document.getElementsByName('testmedownelement').value = "XXXXXX", I am looking for a C# equivalent since I can't use java script in my console application
This is the javascript code: document.getElementsByName('testmedownelement').value = "XXXXXX", I am looking for a C# equivalent since I can't use java script in my console application
C#:
WebRequest request = WebRequest.Create("www.~~~~~~~~~~~~~~~~~~~~~~.com");
request.Method = "GET";
request.ContentType = "application/html";
// Get the response.
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
//Display Status
Console.WriteLine(response.StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
Console.WriteLine(responseFromServer);
// Cleanup the streams and the response.
reader.Close();
dataStream.Close();
response.Close();
Console.ReadKey();