Search code examples
xamarinxamarin.androidandroid-webview

How to read the value from the username text box of my login page loaded in the xamarin android web view


I'm trying to get the value in the user name text box from my login page after the user entered it in a web page using webview in Xamarin android.

I tried using "document.getelementbyid('useranme').values"

but it is always returning null values. Can any one please help ?


Solution

  • Eventually I have found the solution for my problem.

    I have user OnLoadResource function in webview which helped me to get the datas I was searching for

    public override void OnLoadResource(WebView view, string url)
    {
        try
        {
            view.EvaluateJavascript("document.getElementById('username').value;", this);
    
        }
        catch (Java.Lang.Exception oe)
        {
    
        }
        base.OnLoadResource(view, url);
    }
    

    Thanks.