Solved

Configure a button to launch a webpage

Posted on 2014-09-26
5
174 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 6

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 6

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 6

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

792 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