I am creating a basic MCQ app where 2 MCQ's along with options are showed on a single page and the submit button shows the results on the second page in a textblock.
I am using Frame.Navigate(typeof(Page2))
method of navigation which can pass one parameter but, can't pass multiple parameters to the next page.
Here is my code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.Popups;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=391641
namespace MCQ
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.NavigationCacheMode = NavigationCacheMode.Required;
}
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached.
/// This parameter is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// TODO: Prepare page for display here.
// TODO: If your application contains multiple pages, ensure that you are
// handling the hardware Back button by registering for the
// Windows.Phone.UI.Input.HardwareButtons.BackPressed event.
// If you are using the NavigationHelper provided by some templates,
// this event is handled for you.
}
private void button_Click(object sender, RoutedEventArgs e)
{
string ans1 = "";
string ans2 = "";
if (radioButton.IsChecked == true)
{
ans1 = "Answer 1 is correct";
}
else
{
ans1 = "Answer 1 is incorrect";
}
if (radioButton2.IsChecked == true)
{
ans2 = "Answer 2 is correct";
}
else
{
ans2 = "Answer 2 is incorrect";
}
Frame.Navigate(typeof(Page2), ans1, ans2);
//textBlock3.Text = ans1 + " & " + ans2; ;
}
private void button1_Click(object sender, RoutedEventArgs e)
{
}
}
}
I get the error cannot convert from string to windows.ui.xaml.media. navigation.transitioninfo on the second parameter i.e. ans2.
Any help would be appreciated or an alternate way to pass parameters to next page. THanks!
It was server error due to mod security. It got solved. Thank you guys