Tech
Forums
Jobs
Books
Events
Live
Interviews Prep
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
4
Reply
how to use switch statement to navigate between url c#
Abbas Hamza
Apr 12 2016 7:09 AM
436
Reply
i have this method which will take 1 url :
public
static
void
LaunchSite(Uri sitUrl)
{
SHDocVw.ShellWindows w =
new
SHDocVw.ShellWindows();
bool
found =
false
;
foreach
(SHDocVw.ShellBrowserWindow item
in
w)
{
var doc = item.LocationURL;
if
(!
string
.IsNullOrEmpty(doc))
if
(doc == sitUrl.AbsoluteUri)
{
found =
true
;
break
;
}
}
if
(!found)
Process.Start(sitUrl.AbsoluteUri);
}
button event handler looks like this
private
void
btnSubs_Click(
object
sender, RoutedEventArgs e)
{
//StartProcess.webSit();
Uri oxfArt =
new
Uri(@
"http://www.oxfordartonline.com/subscriber/"
);
Uri theoryTst =
new
Uri(
"http://theorytestpro.co.uk/"
);
string
webAddress = oxfArt.OriginalString;
switch
(webAddress)
{
case
"http://www.oxfordartonline.com/subscriber/"
:
StartProcess.LaunchSite(oxfArt);
break
;
case
"http://theorytestpro.co.uk/"
:
StartProcess.LaunchSite(theoryTst);
break
;
default
:
break
;
}
}
the button event handler will handle multiple buttons so depending on which button clicked need to determine which Uri need to be launched using switch statement. thank you
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
c# code to assign the diff route after splitting the file?
insert item from listbox to textbox