Advertisement
DrAungWinHtut

BrowserinCS

Mar 30th, 2022
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11.  
  12. namespace NewTools
  13. {
  14.     public partial class frmBrowser : Form
  15.     {
  16.         public frmBrowser()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.  
  21.      
  22.  
  23.         private void btnSearch_Click(object sender, EventArgs e)
  24.         {
  25.             string sAddress = txtAddress.Text;
  26.             string sHeader = sAddress.Substring(0, 4);
  27.             Uri uri = new Uri(sAddress, UriKind.RelativeOrAbsolute);
  28.             if (!uri.IsAbsoluteUri)
  29.             {
  30.                 if(sHeader == "www.")
  31.                 {
  32.                     sAddress = "https://" + sAddress;
  33.                 }
  34.                 else
  35.                 {
  36.                     sAddress = "https://www." + sAddress;
  37.                 }
  38.                 Uri uri2 = new Uri(sAddress, UriKind.RelativeOrAbsolute);
  39.                 brsHomepage.Navigate (uri2);
  40.             }
  41.             else
  42.             {
  43.                 brsHomepage.Navigate(uri);
  44.             }
  45.  
  46.         }
  47.     }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement