Solved

Configure a button to launch a webpage

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

777 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