win8外包公司——技术分享:参数传递
2013-12-08 18:20
176 查看
页面之间传递参数
windows phone 的参数传递和web 差不多。用“?”号传递 多个参数的时候用 “&”做分隔。
我接着昨天的项目继续添加一个FourPage.xaml
在昨天的ThreePage.xaml中添加两个 TextBlock控件分别在Text 中写上 “用户名",”密码"。 再添加两个TextBox控件,分别取名txtUserName,txtPassword
。接着添加一个按钮Button 取名toFourPage。然后双击按钮在 toFourPage 的单击事件中添加如下代码:
[csharp] view plaincopyprint?
private void toFourPage_Click(object sender, RoutedEventArgs e)
{
//判断用户名,密码是否为空
string username = this.txtUserName.Text;
string password = this.txtPassword.Text;
if (username == "")
{
MessageBox.Show("用户名为空");
return;
}
else if (password == "")
{
MessageBox.Show("你再怎么也瞎填点东西。");
return;
}
else
{
this.NavigationService.Navigate(new Uri("/FourPage.xaml?UserName=" + username + "&Password=" + password,UriKind.Relative));
}
}
然后我们继续添在FourPage.xaml 中添加两个 TextBlock 用来存放 传递过来的参数。按F7进入代码页面。添加代码如下:
[csharp] view plaincopyprint?
//上一章讲的OnNavigatedTo事件。当从其他页过来的时候。
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
this.UserName.Text = this.NavigationContext.QueryString["UserName"];
this.Password.Text = this.NavigationContext.QueryString["Password"];
}
OK 启动模拟器,先进到我们昨天添加的 页面三(ThreePgae.xaml)我在用户名中填写 任意值,继续在密码框中填写任意值点击登录。(注:因为这章主要是讲页面值的传递,以为密码框用的明文。)
OK 页面中最简单值的传递就 演示完了。
(写的不好 请见谅,有不对请留言告知我,免得误人子弟。)
代码下载 地址 http://download.csdn.net/download/gongkepop/6042391
ref /article/1868594.html
windows phone 的参数传递和web 差不多。用“?”号传递 多个参数的时候用 “&”做分隔。
我接着昨天的项目继续添加一个FourPage.xaml
在昨天的ThreePage.xaml中添加两个 TextBlock控件分别在Text 中写上 “用户名",”密码"。 再添加两个TextBox控件,分别取名txtUserName,txtPassword
。接着添加一个按钮Button 取名toFourPage。然后双击按钮在 toFourPage 的单击事件中添加如下代码:
[csharp] view plaincopyprint?
private void toFourPage_Click(object sender, RoutedEventArgs e)
{
//判断用户名,密码是否为空
string username = this.txtUserName.Text;
string password = this.txtPassword.Text;
if (username == "")
{
MessageBox.Show("用户名为空");
return;
}
else if (password == "")
{
MessageBox.Show("你再怎么也瞎填点东西。");
return;
}
else
{
this.NavigationService.Navigate(new Uri("/FourPage.xaml?UserName=" + username + "&Password=" + password,UriKind.Relative));
}
}
private void toFourPage_Click(object sender, RoutedEventArgs e) { //判断用户名,密码是否为空 string username = this.txtUserName.Text; string password = this.txtPassword.Text; if (username == "") { MessageBox.Show("用户名为空"); return; } else if (password == "") { MessageBox.Show("你再怎么也瞎填点东西。"); return; } else { this.NavigationService.Navigate(new Uri("/FourPage.xaml?UserName=" + username + "&Password=" + password,UriKind.Relative)); } }
然后我们继续添在FourPage.xaml 中添加两个 TextBlock 用来存放 传递过来的参数。按F7进入代码页面。添加代码如下:
[csharp] view plaincopyprint?
//上一章讲的OnNavigatedTo事件。当从其他页过来的时候。
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
this.UserName.Text = this.NavigationContext.QueryString["UserName"];
this.Password.Text = this.NavigationContext.QueryString["Password"];
}
//上一章讲的OnNavigatedTo事件。当从其他页过来的时候。 protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedFrom(e); this.UserName.Text = this.NavigationContext.QueryString["UserName"]; this.Password.Text = this.NavigationContext.QueryString["Password"]; }
OK 启动模拟器,先进到我们昨天添加的 页面三(ThreePgae.xaml)我在用户名中填写 任意值,继续在密码框中填写任意值点击登录。(注:因为这章主要是讲页面值的传递,以为密码框用的明文。)
OK 页面中最简单值的传递就 演示完了。
(写的不好 请见谅,有不对请留言告知我,免得误人子弟。)
代码下载 地址 http://download.csdn.net/download/gongkepop/6042391
ref /article/1868594.html
相关文章推荐
- 【自动化测试技术QTP基础系列十一】---Action之间的参数传递
- 多进程参数传递技术探讨
- 分页技术框架(Pager-taglib)学习三(pager-taglib中传递参数时中文乱码问题)
- 【厚积薄发】技术分享连载(八十二)| 实现动态合批的条件| 渲染模块需关注的参数指标| 移动端上的阴影实现方式...
- ASP 模板技术之参数传递
- Java核心技术 卷一 笔记十 参数传递设计的调用
- ibatis参数传递小技巧 - 疯狂的菠菜 - ITeye技术网站
- 分享自cole3 《u-boot向linux内核传递启动参数》
- 反射技术动态调用方法中的引用类型参数传递 (转)
- 浅谈TC、BC和汇编混合编程连接技术及参数传递方法
- 清华大学计算中心培训部-技术分享:Java基础入门:不定长度参数
- 一起谈.NET技术,在Silverligh中调用Javascript (四种调用方法+简单与复杂参数的传递)
- Spring MVC参数传递中文乱码解决方法分享
- 分享:C++参数传递方式
- Java中用户向系统传递参数的三种基本方式实例分享
- 开源技术分享:Linux 内核参数 swappiness细解
- AJAX技术使用XMLHttpRequest对象传递参数的中文乱码问题
- PHP函数参数传递方法的具体改进技巧分享
- QTP关键技术(四) - Test和Top-Level Action间参数传递
- 64位下好神奇啊(增加了PatchGuard技术保护自己,SSDT是相对地址,参数通过寄存器与rdi来传递)