here is an example
C#
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
Ken6 pointsPosted Oct 14, 2006, 2:29 PM EDT
try
{
<Insert your code here. If an exception occurs, then it creates an exception below.>
}
N5 pointsPosted Oct 15, 2006, 4:12 AM EDT
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 !!
}
Ken6 pointsPosted Oct 15, 2006, 6:05 AM EDT
try
{
webbrowser1.navigate(@"x.htm") ; ///this file does not exist it only fires an error !!
}
N5 pointsPosted Oct 15, 2006, 7:14 AM EDT
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 there
webBrowser2.Navigate (@"s.html") ; or webBrowser2.navigate("");
//MessageBox.Show(Convert.ToString(ex));
}
thanx