Solved

Configure a button to launch a webpage

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
install app on other machine 13 32
Stream.BeginRead and Stream.EndRead in .NET Core 5 37
Angular - break the dataset in chunks? 7 39
Wav problem 4 13
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

910 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

23 Experts available now in Live!

Get 1:1 Help Now