Sir Learnalot
asked on
Button not working - launching a webpage from a button in C#
Hello Everyone, I made a form (WPF User Control) with a textbox called Tracking_Num, a comboBox called Courier_List, and a button called Tracking_Button. The idea is the user selects a courier, enters the tracking number, and hits track to launch the default browser and track the package using the provided courier and tracking #.
The button is completely not working - nothing happens when I click it not even an error.
Here is my XML code:
Here is my C# code:
The button is completely not working - nothing happens when I click it not even an error.
Here is my XML code:
<ComboBox x:Name="Courier_List" Margin="102,363.711,83,125.874" ItemsSource="{Binding Path=Courier_List, Mode=Default, UpdateSourceTrigger=PropertyChanged}" >
<ComboBoxItem x:Name="UPS" Content="UPS"/>
<ComboBoxItem x:Name="FedEX" Content="FedEX"/>
<ComboBoxItem x:Name="UPS_SCS" Content="UPS SCS"/>
</ComboBox>
<TextBox x:Name="Tracking_Num" Margin="102,393.2,83,96.237" Text="{Binding Path=Tracking_Num, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<Button x:Name="Tracking_Button" Content="Track!" HorizontalAlignment="Left" Margin="284.6,393.2,0,0" VerticalAlignment="Top" Width="75" Height="24.8" Click="Tracking_Button_Click">
Here is my C# code:
<ComboBox x:Name="Courier_List" Margin="102,363.711,83,125.874" ItemsSource="{Binding Path=Courier_List, Mode=Default, UpdateSourceTrigger=PropertyChanged}" >
<ComboBoxItem x:Name="UPS" Content="UPS"/>
<ComboBoxItem x:Name="FedEX" Content="FedEX"/>
<ComboBoxItem x:Name="UPS_SCS" Content="UPS SCS"/>
</ComboBox>
<TextBox x:Name="Tracking_Num" Margin="102,393.2,83,96.237" Text="{Binding Path=Tracking_Num, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<Button x:Name="Tracking_Button" Content="Track!" HorizontalAlignment="Left" Margin="284.6,393.2,0,0" VerticalAlignment="Top" Width="75" Height="24.8" Click="Tracking_Button_Click">
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try the navigation window.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Per https://www.experts-exchange.com/questions/28541134/Button-not-working-launching-a-webpage-from-a-button-in-C.html?anchorAnswerId=40393251#a40393251 the suggestion was to first format the URL and then call the System.Diagnostics.Process .Start.
Since the code hasn't changed much I can only assume the issue was with how the URL was being formatted. Had you had used the the https://google.com as an example you would have seen it was an issue with the URL. I believe full points should be warranted for this.
Since the code hasn't changed much I can only assume the issue was with how the URL was being formatted. Had you had used the the https://google.com as an example you would have seen it was an issue with the URL. I believe full points should be warranted for this.
ASKER
@Kyle
1. The way the points system is setup, I can't recant the points I awarded (as far as I am aware).
2. If you read the posts thoroughly, you would have discovered I had already been using that format for my strings... I even explicitly said it in my post. The problem was not the format of the URL at all actually, had you read my solution you would realize I used SelectedIndex instead of SelectedValue, and changed the case to match the index # instead of looking for a string match...
3. Your answers literally helped me 0%. I actually requested attention on the topic because it was clear to me the answers were not pointing in the right direction... I had a hunch the problem was in the passing of the selection to the button handler... and I was correct. The only reason I gave you points is for effort, because you took the time to reply to my post. 250 points is more than generous.
I am sorry that you are not pleased with how I marked the solution, I hope that my explanation gave you some insight as to why it was awarded the way it was.
Have a great day and enjoy the rest of your week :)
1. The way the points system is setup, I can't recant the points I awarded (as far as I am aware).
2. If you read the posts thoroughly, you would have discovered I had already been using that format for my strings... I even explicitly said it in my post. The problem was not the format of the URL at all actually, had you read my solution you would realize I used SelectedIndex instead of SelectedValue, and changed the case to match the index # instead of looking for a string match...
3. Your answers literally helped me 0%. I actually requested attention on the topic because it was clear to me the answers were not pointing in the right direction... I had a hunch the problem was in the passing of the selection to the button handler... and I was correct. The only reason I gave you points is for effort, because you took the time to reply to my post. 250 points is more than generous.
I am sorry that you are not pleased with how I marked the solution, I hope that my explanation gave you some insight as to why it was awarded the way it was.
Have a great day and enjoy the rest of your week :)
ASKER
I have provided points for effort but my solution was done completely independently. Thanks for all your efforts!
ASKER
I was already using the System.Diagnostics.Process
Open in new window