Solved

Configure a button to launch a webpage

Posted on 2014-09-26
5
164 Views
Last Modified: 2014-10-05
Hello everyone,
I have made a custom form using Visual Studio. The form many elements, three of which are a list, button, and text field. The list contains 3 different shipping companies used to ship an item, the text field contains a tracking # and the button is called "Track!". The desired action is for the user to select a shipping company from the list, enter the tracking number for that item, and hit the "Track!" button. This should launch the appropriate webpage (according to which shipper was selected) and should automatically pass the tracking number as a parameter.

I am not sure how to exactly program it. I found some sample code on how to do this as a console task but I would prefer to have it built in to my form and launch from the button instead... I have provided the console code in case it will help anyone figure out how to embed it in my assembly.

Thanks in advance.

/C if "$Context/Property[Type='MyWorkItem']/Courier$" == "UPS" (start http://wwwapps.ups.com/ietracking/tracking.cgi?loc=CA_CA^&tracknum^="$Context/Property[Type='MyWorkItem']/TrackingNumber$") else (if "$Context/Property[Type='MyWorkItem']/Courier$" == "FedEX" (start https://www.fedex.com/fedextrack/index.html?tracknumbers^="$Context/Property[Type='MyWorkItem']/TrackingNumber$"^&locale=en_CA^&cntry_code=ca_english) else (if "$Context/Property[Type='MyWorkItem']/Courier$" == "UPS SCS" (start https://www.upspostsaleslogistics.com/cfw/trackOrder.do?trackNumber^="$Context/Property[Type='MyWorkItem']/TrackingNumber$")))

Open in new window

0
Comment
Question by:Sir Learnalot
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:hjgode
ID: 40347267
Normally you just have to let windows start the html associated application:
System.Diagnostics.Process.Start(url);
Where is the problem?
0
 
LVL 5

Author Comment

by:Sir Learnalot
ID: 40350191
There is no problem except for me not knowing how to do it :) If you could provide some more direction/guidance I would greatly appreciate it. Thanks in advance for your time.
0
 
LVL 16

Assisted Solution

by:hjgode
hjgode earned 500 total points
ID: 40350258
In your button click handler:

string urlUPS=String.Format("http://wwwapps.ups.com/ietracking/tracking.cgi?loc=CA_CA&tracknum={0}", trackingnumber);

System.Diagnostics.Process.Start(urlUPS);

I am not sure how your url must look exactly. I would suggest you look at the URL when you do a manual request. The variable trackingnumber has the string with the tracking number. You need to extend the above for the different parcel services.

google says:
http://wwwapps.ups.com/ietracking/tracking.cgi?loc=CA_CA&tracknum=1Z29491A6800772688
0
 
LVL 5

Accepted Solution

by:
Sir Learnalot earned 0 total points
ID: 40353002
I ended up solving this on my own.
 <Button x:Name="Tracking_Button" Content="Track!" HorizontalAlignment="Left" Margin="284.6,393.2,0,0" VerticalAlignment="Top" Width="75" Height="24.8" Cursor="Cross" ToolTip="Track the provided tracking number at the provided couriers website!" Click="Tracking_Button_Click">
  <Button.Background>
       <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
            <GradientStop Color="#FFF3F3F3" Offset="0"/>
            <GradientStop Color="#FFEBEBEB" Offset="0.5"/>
            <GradientStop Color="#FFDDDDDD" Offset="0.5"/>
      </LinearGradientBrush>
  </Button.Background>

Open in new window


 private void Tracking_Button_Click(object sender, RoutedEventArgs e)
        {
            switch (Courier_List.SelectedValue.ToString())
            {
                case "UPS":
                System.Diagnostics.Process.Start("http://wwwapps.ups.com/ietracking/tracking.cgi?loc=CA_CA^&tracknum^=" + Tracking_Num.Text.ToString());
                break;

                case "FedEX":
                System.Diagnostics.Process.Start("https://www.fedex.com/fedextrack/index.html?tracknumbers^="+Tracking_Num.Text.ToString()+"^&locale=en_CA^&cntry_code=ca_english");
                break;

                case "UPS SCS":
                System.Diagnostics.Process.Start("https://www.upspostsaleslogistics.com/cfw/trackOrder.do?trackNumber^=" + Tracking_Num.Text.ToString());
                break;

                default:
                break;
            }
        }

Open in new window

0
 
LVL 5

Author Closing Comment

by:Sir Learnalot
ID: 40361881
I ended up figuring out how to implement it in my code on my own, but gave points to user for attempting to guide me.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now