here is an example
void
TreeView1AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e){
string x = e.Node.Text ; switch(x){
case"Node1":webBrowser1.Navigate (@"\s.html"); ////this works fine
webBrowser2.Navigate (@"\x.html"); ///this works fine too
break;
case"Node2":
webBrowser1.Navigate (@"\s.html"); ////this works fine
webBrowser2.Navigate (@"\x.htmlx"); ///i dont have this file becouse i want to create an error !!
i want to catch this error and it must load an empy file of or navigate to ("")
if the file does not exist then dont wat a messagebox with error etc etc...only load an empty file if the file does not exist.visa versa for webbrowser1.navigate(@"\s.html");
break;
}
i can't vigerout how to solf this problem.
i have try this
if (webbrowser.Document != null)
this does not work becouse it looks only if document is loaded or not.
i have tryd many if and else statements and try and catch bloks nothing works.
please help.
thanks
NPosted Oct 15, 2006, 11:14 AM
it works great ...but.... it can't load the file it wil go on the internet or it shows a file that says that the page does not exist an chek the path etc etc..
i only wil work offline not to surf the internet !!
ho do i get a blank page or file int to the webbrowser2 if it catches the error ?
i have tryd this
try
{
webBrowser2.Navigate(@"x.htmx") ; ///this file does not exist it only fires an error !!}
catch
(Exception ex){
////this should be got to these file but it wont go therewebBrowser2.Navigate (@"s.html") ; or webBrowser2.navigate("");
//MessageBox.Show(Convert.ToString(ex));
}
thanx
KenPosted Oct 15, 2006, 10:05 AM
try
{
webbrowser1.navigate(@"x.htm") ; ///this file does not exist it only fires an error !!
}
catch (Exception ex)
{
//MessageBox.Show(Convert.ToString(ex));
}
NPosted Oct 15, 2006, 8:12 AM
thanx for jour help but i does not work i stil get an messagebox that says that the file does not exist en chek it etc etc.
i want that if a file does not exist that it shows only a blank file or nothing no errors etc etc.
i have used jour solution see example below
try
{
webbrowser1.navigate(@"x.htm") ; ///this file does not exist it only fires an error !!
}
catch (Exception ex)
{
MessageBox.Show(Convert.ToString(ex));
}
KenPosted Oct 14, 2006, 6:29 PM
try
{
}
catch
(Exception ex){
MessageBox.Show(Convert.Tostring(ex));
}