当前位置:网站首页>ASP. Net cross page submission (button control page redirection)
ASP. Net cross page submission (button control page redirection)
2022-06-29 21:50:00 【Eighty eight old】
newly build web forms
Cross1.aspx
Cross2.aspx
1、 Set source page Button The control of PostBackUrl attribute Set as target page path
PostBackUrl="~/Chap2/Cross2.aspx"
2、 Add... In the header of the target page **@PreviousPageType Instructions **, Set properties VirtualPath Is the source page path
<%@ PreviousPageTypeVirtualPath=="~/Chap2/Cross1.aspx"%>
Cross1.aspx Complete code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Cross1.aspx.cs" Inherits="Chap2_Cross1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
user name :<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<br />
password :<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
<br />
<asp:Button ID="btnSubmit" runat="server" Text=" confirm " PostBackUrl="~/Chap2/Cross2.aspx" />
</div>
</form>
</body>
</html>
3、 There are two ways to access source page data on the target page
Use public attributes to get values
Get values using control properties
Key code
public string Name
{
get {
return txtName.Text; }
}
// Use public attributes to get values
lblMsg.Text = " user name :" + PreviousPage.Name + "<br/>";
// Get values using control properties
TextBox txtPassword = (TextBox)PreviousPage.FindControl("txtPassword");
lblMsg.Text += " password :" + txtPassword.Text;
Cross1.aspx.cs Complete code
public partial class Chap2_Cross1 : System.Web.UI.Page
{
public string Name
{
get {
return txtName.Text; }
}
}
Cross2.aspx Complete code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Cross2.aspx.cs" Inherits="Chap2_Cross2" %>
<%@ PreviousPageType VirtualPath="~/Chap2/Cross1.aspx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblMsg" runat="server" ></asp:Label>
</div>
</form>
</body>
</html>
Cross2.aspx.cs Complete code
using System;
using System.Web.UI.WebControls;
public partial class Chap2_Cross2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(PreviousPage.IsCrossPagePostBack)// Determine whether it is cross page submission
{
// Use public attributes to get values
lblMsg.Text = " user name :" + PreviousPage.Name + "<br/>";
// Get values using control properties
TextBox txtPassword = (TextBox)PreviousPage.FindControl("txtPassword");
lblMsg.Text += " password :" + txtPassword.Text;
}
}
}


边栏推荐
- 2022 openvino DevCon unveils secrets! Intel and many partners deepen the construction of developer ecology and release the innovation potential of AI industry
- STM32 minimum system construction (schematic diagram)
- verilog实现DDS波形发生器模块,可实现频率、相位可调,三种波形
- Digital password lock Verilog design + simulation + on board verification
- 什么是 SYN 洪水攻击?如何防护?
- 唯品会商品详情API接口(item_get-获得唯品会商品详情接口),唯品会详情API接口
- My creation anniversary
- Amazon Product details API interface - (item_get get Amazon Product details interface), Amazon details API interface
- BUAA OO unit 4 HW16 unit 4 Summary and course review
- Reading notes on how to connect the network - LAN on the server side (4)
猜你喜欢

Yolov6 training your own data record +yolov5 comparison test
![[advanced ROS] Lecture 3 ROS file system and distributed communication](/img/9f/2c316f5b0aa36b63769672048da772.png)
[advanced ROS] Lecture 3 ROS file system and distributed communication

直播预告 | PostgreSQL 内核解读系列第一讲:PostgreSQL 系统概述

Layer 3 loop brought by route Summary - solution experiment

【ROS进阶篇】第三讲 ROS文件系统与分布式通信

Knowledge distilling learning notes

leetcode:238. Product of arrays other than itself

After inventing anti-virus software, he chose to be a top-notch gangster

Bs-gx-017 online examination management system based on SSM

Recruit | DBA Data Engineer every week with an annual salary of 35+. Dream of Kyushu and bright stars!
随机推荐
Structure the fifth operation of the actual camp module
A new Polaris has risen!
状态管理 利用Session限制页面访问 只有通过登录验证SessionLogin.aspx才能访问Session.aspx
CORDIC based Signal Processor desgn
Which brokerage commission is the lowest and safest
小型图书馆项目总结
About Effect Size
Realize inotify and Rsync real-time backup
leetcode:307. Area and retrieval - array modifiable
Résumé du projet de petite bibliothèque
Taro applet enables wxml code compression
唯品会关键词搜索API接口(item_search-按关键字搜索唯品会商品API接口),唯品会API接口
[advanced ROS] Lecture 3 ROS file system and distributed communication
BUAA OO unit 4 HW16 unit 4 Summary and course review
Divide the bonus pool of 10million + million yuan, and empower developers in the 2022 shengteng AI innovation competition
Matlab adds noise / disturbance to data
Redis (I) -- getting started with redis (1) -- redis introduction, installation and startup, and common configurations
Writing a makefile for a golang project
PostgreSQL Weekly News - 22 juin