I need to validate textbox so that it can only take website url up-to domain code only.
For e.g. User must insert website url as "http://www.google.com".
If user insert "http://www.codeproject.com/Articles/334310/Understanding-ASP-NET-Validation-Techniques" then it should not allow.
Allowed:-"http://www.google.com"
Not Allowed:-"http://www.codeproject.com/Articles/334310/Understanding-ASP-NET-Validation-Techniques"
Please help.
Rajeesh MenothPosted Sep 11, 2015, 12:22 PM
private void btnGo_Click(object sender, EventArgs e) { webBrowser1.Navigate(txtUrl.Text); }// Verify that this is an allowed web site. private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e) { if (e.Url.Host != "www.csharphelper.com") { e.Cancel = true; MessageBox.Show("This web site is prohibited", "Prohibited", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }