当前位置:网站首页>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;
}
}
}


边栏推荐
- About Effect Size
- Which brokerage commission is the lowest and safest
- Viewing technological changes through Huawei Corps (V): smart Park
- As a developer, you need to know about the codeless development platform IVX
- Layer 3 loop brought by route Summary - solution experiment
- R language plot visualization: plot visualization box graph and several box plots of multiple classification variables
- 阿里巴巴店铺的所有商品API接口(item_search_shop-获得店铺的所有商品接口),阿里巴巴API接口
- A new Polaris has risen!
- Flame retardant test of aluminum sheet as/nzs 1530.1 non combustible materials
- 不同系统下的文件层级符号小结
猜你喜欢

Report delivery engineer

Golang operation NSQ distributed message queue
![[cloud native] use of Nacos taskmanager task management](/img/ad/24bdd4572ef9990238913cb7cd16f8.png)
[cloud native] use of Nacos taskmanager task management


JD alliance API - universal chain transfer interface - Jingpin library interface - Interface Customization

Threejs basic introduction
![[advanced ROS chapter] Lecture 4: duplicate names in ROS (nodes, topics and parameters)](/img/25/85e8c55605f5cc999a8e85f0a05f93.jpg)
[advanced ROS chapter] Lecture 4: duplicate names in ROS (nodes, topics and parameters)

每周招聘|DBA数据工程师,年薪35+ ,梦起九州,星河灿烂!

Bs-gx-017 online examination management system based on SSM
![[advanced ROS chapter] lesson 2 custom header and source file encapsulation](/img/25/85e8c55605f5cc999a8e85f0a05f93.jpg)
[advanced ROS chapter] lesson 2 custom header and source file encapsulation
随机推荐
Design of VHDL telephone billing system
Rsync method of establishing multi directory module
Aleph farms hired a supervisor of regulatory affairs to prepare for global commercialization in advance
The solution to the "undefined symbol: \u cxa\throw\bad\array\new\u length, version qt\u 5" error reported by the Kirin system startup application
MES系统与ERP如何集成?本文告诉你答案
Change detection and batch update
[advanced ROS chapter] Lecture 4: duplicate names in ROS (nodes, topics and parameters)
透过华为军团看科技之变(五):智慧园区
PostgreSQL weekly news - June 22
[cloud native] use of Nacos taskmanager task management
flutter BottomNavigationBar切换页面保持状态
Implementing LDAP proxy service with haproxy + keepalive
唯品会商品详情API接口(item_get-获得唯品会商品详情接口),唯品会详情API接口
PostgreSQL每周新聞—6月22日
Implementation and Simulation of ads131a04 ADC Verilog
The explain function of the DALEX package of R language generates a machine learning model interpreter and predict for the specified classification prediction_ The parts function analyzes the contribu
leetcode:724. 寻找数组的中心下标
什么是 SYN 洪水攻击?如何防护?
How to integrate MES system with ERP? This article tells you the answer
Desai wisdom number - other charts (basic sunrise chart): high frequency words in graduation speech