I'm currently using a WebBrowser control in a C# WinForms application, and attempting to control some variability presented with this control.
Basically, my users log in to a separate UI provided by my application, which then displays the WebBrowser control, navigates to a predetermined log-in URL, and then auto-fills the username and password fields on that page.
However, in order to prevent unpredictable behavior in this WebBrowser control, I want to make these username and password text boxes read-only after they are auto-populated. Essentially, I want the user to see a browser page that has been filled out for them, and that cannot be edited. (This is so that any authentication errors can be handled by my application as opposed to the browser.)
The code I'm currently using to populate the text fields and make them read only is as follows:
webBrowser1.Document.GetElementById("username").InnerText = username;
webBrowser1.Document.GetElementById("password").InnerText = password;
webBrowser1.Document.GetElementById("username").Enabled = false;
webBrowser1.Document.GetElementById("password").Enabled = false;
Unfortunately, when I try to make the fields read-only, the authentication server acts like the password field was not filled out, and prompts the user to fill it out again after the "Submit" button is clicked. Is this expected behavior, and if so, what other methods can I try to prevent users from changing the credentials that the browser was auto-populated with?