我正在windows phone 7应用程序中构建一个应用程序。我的申请表中有一份表格。表单的代码是:
XAML:
<TextBox GotFocus="OnGotFocus" Canvas.Left="6" Canvas.Top="6" Height="74" Name="name" Text="*Name" Width="453" BorderThickness="0"/>
<TextBox GotFocus="OnGotFocus1" Canvas.Left="6" Canvas.Top="66" Height="74" Name="age" Text="*Age" Width="453" BorderThickness="0" />
<TextBlock Canvas.Left="20" Canvas.Top="157" Height="44" Name="gen" Text="Gender" Foreground="Black" FontFamily="Verdana" FontSize="24" Width="134" />
<RadioButton Canvas.Left="139" Canvas.Top="157" FontStyle="Italic" GroupName="Gender" Foreground="Black" Content="Male" Height="71" Name="male" Width="154" />
<RadioButton Canvas.Left="139" Canvas.Top="207" FontStyle="Italic" GroupName="Gender" Foreground="Black" Content="Female" Height="71" Name="fem" Width="140" />
<TextBox GotFocus="OnGotFocus2" Canvas.Left="6" Canvas.Top="267" Height="74" Name="sadd" Text="*Street Address" Width="453" BorderThickness="0"/>
<TextBox GotFocus="OnGotFocus3" Canvas.Left="6" Canvas.Top="327" Height="74" Name="cadd" Text="*City Address" Width="453" BorderThickness="0"/>
<TextBox GotFocus="OnGotFocus4" Canvas.Left="6" Canvas.Top="387" Height="74" Name="eadd" Text="*Email Address" Width="453" BorderThickness="0"/>
<TextBox GotFocus="OnGotFocus5" Canvas.Left="6" Canvas.Top="447" Height="74" Name="phn" Text="*Phone" Width="453" BorderThickness="0"/>
<TextBox GotFocus="OnGotFocus6" Canvas.Left="6" Canvas.Top="507" Height="74" Name="zip" Text="*Zip Code" Width="453" BorderThickness="0"/>
现在单击提交按钮我想生成一个pdf,其中应包含我在表单中输入的数据以及一些手动数据。生成的pdf应该像电子邮件中的附件一样发送,之后数据应该以特定的Web方法提交,即“registertoteam”。任何人都可以帮我提供有关如何执行此操作的代码。我目前的cs文件看起来像这样:
namespace KejriwalPhoneApp
{
public partial class Join : PhoneApplicationPage
{
public Join()
{
InitializeComponent();
}
private void OnGotFocus(object sender, RoutedEventArgs e)
{
if (name.Text.Equals("*Name", StringComparison.OrdinalIgnoreCase))
{
name.Text = string.Empty;
}
}
private void OnGotFocus1(object sender, RoutedEventArgs e)
{
if (age.Text.Equals("*Age", StringComparison.OrdinalIgnoreCase))
{
age.Text = string.Empty;
}
}
private void OnGotFocus2(object sender, RoutedEventArgs e)
{
if (sadd.Text.Equals("*Street Address", StringComparison.OrdinalIgnoreCase))
{
sadd.Text = string.Empty;
}
}
private void OnGotFocus3(object sender, RoutedEventArgs e)
{
if (cadd.Text.Equals("*City Address", StringComparison.OrdinalIgnoreCase))
{
cadd.Text = string.Empty;
}
}
private void OnGotFocus4(object sender, RoutedEventArgs e)
{
if (eadd.Text.Equals("*Email Address", StringComparison.OrdinalIgnoreCase))
{
eadd.Text = string.Empty;
}
}
private void OnGotFocus5(object sender, RoutedEventArgs e)
{
if (phn.Text.Equals("*Phone", StringComparison.OrdinalIgnoreCase))
{
phn.Text = string.Empty;
}
}
private void OnGotFocus6(object sender, RoutedEventArgs e)
{
if (zip.Text.Equals("*Zip Code", StringComparison.OrdinalIgnoreCase))
{
zip.Text = string.Empty;
}
}
private void Image_Previous(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/AAP.xaml", UriKind.Relative));
}
private void submit_Click(object sender, RoutedEventArgs e)
{
if (name.Text == String.Empty)
{
MessageBox.Show("Please Enter the name");
name.Focus();
}
if (age.Text == String.Empty)
{
MessageBox.Show("Please Enter the age");
age.Focus();
}
if (male.IsChecked == true)
{
string gender = male.Content.ToString();
}
else if (fem.IsChecked == true)
{
string gender = fem.Content.ToString();
}
else //none of them is selected.
{
MessageBox.Show("Please select your Gender");
}
if (sadd.Text == String.Empty)
{
MessageBox.Show("Please Enter the Street Address");
sadd.Focus();
}
if (cadd.Text == String.Empty)
{
MessageBox.Show("Please Enter the City Address");
cadd.Focus();
}
if (eadd.Text == String.Empty)
{
MessageBox.Show("Please Enter the Email Address");
eadd.Focus();
}
if (phn.Text == String.Empty)
{
MessageBox.Show("Please Enter the Phone Number");
phn.Focus();
}
if (zip.Text == String.Empty)
{
MessageBox.Show("Please Enter the Zipcode");
zip.Focus();
}
}
private void reset_Click(object sender, RoutedEventArgs e)
{
name.Text = String.Empty;
age.Text = String.Empty;
sadd.Text = String.Empty;
cadd.Text = String.Empty;
eadd.Text = String.Empty;
phn.Text = String.Empty;
zip.Text = String.Empty;
male.IsChecked = false;
fem.IsChecked = false;
}
}
}
我知道如何添加我的Web服务以及如何从Web服务获取数据并将其显示在我的应用程序中。现在我想将这些数据发送到webmethod,这是registertoteam。请帮忙
答案 0 :(得分:1)
我最近在我的一个应用程序中集成了相同的内容。我想出了以下决定
codeplex提供的开源库是没有价值的。它们甚至没有被添加到项目中。
目前,对于Windows Phone开发人员来说,使用它来呈现pdf没有任何支持或任何库可用。
这将是一项有点乏味的任务。至于制作pdf,你需要自己制作完整的pdf文件格式,因为没有图书馆支持。
所以在核心this中这样做是我要推荐的第一个链接。(这解决了你的目的。)此链接也附有源代码。
有关更多且组织良好的解决方案,请检查我的堆栈流question。
关于电子邮件附件,我的和你的坏!到目前为止,开发人员还没有这样的支持。 :(
答案 1 :(得分:0)
我目前无法分享代码,但快速用谷歌搜索我的结果http://pdfsharpwp7.codeplex.com/和http://itextsharpsl.codeplex.com/(推荐)。