TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abbas Hamza
NA
100
53k
how to use switch statement to navigate between url c#
Apr 12 2016 7:09 AM
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
Reply
Answers (
4
)
c# code to assign the diff route after splitting the file?
insert item from listbox to textbox