Solved

Configure a button to launch a webpage

Posted on 2014-09-26
5
176 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ado.net AddWithValue when using IN condition 7 45
Visual Studio hangs on running project 6 85
Good forum hosting with good privacy policy 3 33
What are MicroServices? 4 68
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.
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.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
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.

751 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