3
and I’m having a question here about programming in C#, which I’m in doubt of how to do.
Well, first I have a program C# of Windows Form Application, in it I created 2 Forms, being the main Form1, where has a menu that would be to choose as if it were a script, in general the complete project would be to log a user and password in a certain internet URL.
But that’s it, and in Form1, I put 4 radiobutton, and in these radiobutton each should contain a registration and password. And I also put a button to start such a script. And when it was clicked on such button to start it calls form2, which in it was placed the Webbrowser component.
Even quoted above is ok. My doubt would be as follows. I wanted to know some method of getting back the value of the radiobutton to the other form when clicking the start button. In the radiobutton part it would be a code in the example below, containing the two values and taking the option that is marked, however I wanted to know how I would return this value to go in another form that would be used in the component Webbrowser
if (radioButton0.Checked)
{
rb_matricula = 8020137; //André Venicios
rb_senha = "senha0";
}
else if (radioButton1.Checked)
{
rb_matricula = 7011288; //Clériston Morais Santos
rb_senha = "senha1";
}
else if (radioButton2.Checked)
{
rb_matricula = 5010940; //Daniel Ribeiro Bandeira
rb_senha = "senha2";
}
My Start Script button just put the same redirecting to form2
private void btn_Iniciar_Click(object sender, EventArgs e)
{
frmBrowser navegador = new frmBrowser();
navegador.ShowDialog();
}
Good now going to form2, it will start the Webbrowser component already at the following link
webBrowser1.Navigate("https://172.16.0.47/pessoal/");
Once done, I put the same to get some data from the URL of the existing site. And fill this field, with the value selected on the radiobutton of Form1, that would be this field.
bool pWeb = false;
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if(!pWeb)
{
webBrowser1.Document.GetElementById("usu_login").InnerText = "7011288";
webBrowser1.Document.GetElementById("usu_senha").InnerText = "senha1";
}
pWeb = true;
}
And the final question would be to take the value returned from the radiobutton, and put it in the place where the license plate and the password are. after Innertext, by arranging another method to pass it, after it grabs the element by the ID and inserts it.
If anyone can help me in this doubt of mine, I will be very grateful, because I have stopped in this way how I will pass it and what method I could use to put in place of Innertext.
Right, the issue of the radiobutton I could do this way, creating a new function, however how would return it to go to the button click, and it would only get the return of the value of the radiobutton that is checked?
– SNOT
I got it, it really worked out now, thank you very much
– SNOT