This is a migrated thread and some comments may be shown as answers.

error trapping for WebView Xamarian

1 Answer 134 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 09 Nov 2017, 05:41 PM
Hi, How can I error trapping on WebView. I want to redirect to another page if url not found

      <Button
        android:id="@+id/Button4"
        android:layout_width="380.5dp"
        android:layout_height="1.0dp"
        android:background="#fa3e3e"
        android:textSize="11dp"
        android:layout_marginRight="295.5dp"
        android:visibility="invisible"
        android:text="Load" />
    <AbsoluteLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <WebView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/webView" />
    </AbsoluteLayout>

click event on button4 will load the page:

    protected override void OnCreate(Bundle bundle)
        {
            
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            mWebClient = new WebClient();
            mWebView = FindViewById<WebView>(Resource.Id.webView);
            mButton4 = FindViewById<Button>(Resource.Id.button4);
            mButton4.Click += mButton4_Click;

 void mButton4_Click(object sender, EventArgs e)
        {
        mWebClient.ShouldOverrideUrlLoading(mWebView,"http://something.com");
        }
}
   public class WebClient : WebViewClient
    {
        public override bool ShouldOverrideUrlLoading(WebView view, string url)
        {
            view.LoadUrl(url);  
            return true;
        }
       
    }

Any help?  Thank you

1 Answer, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 09 Nov 2017, 07:50 PM
Hi James,

This question is unrelated to Telerik UI for Xamarin, thus it is out-of-scope of the UI for Xamarin forums. I recommend asking your question on StackOverflow or in the Xamarin forums instead.

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
James
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Share this question
or