Visual Studio 2019 was just released in 2019 and is not yet a stable release. The instructor believes the propertyThe example shows thePostBackUrlof the controlButtonhas a bug, which does not allow the data to be sent across pages. There are other ways to bypass this. You may just use the GET method.
Home.aspx page using the POST method to redirect to the page NextPage.aspx.
No Home.aspx.cs is required.
Just set the property of Button as PostBackUrl="~/NextPage.aspx".
|
⇒ Submit |
|
| Home.aspx |
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Home.aspx.cs" Inherits="WebApplication10.Home" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form id="form1" runat="server">
Name: <asp:TextBox ID="Name1" runat="server"></asp:TextBox>
Email: <asp:TextBox ID="Email1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" PostBackUrl="~/NextPage.aspx"
Text="Submit" />
</form>
</body>
</html>
|
| NextPage.aspx.cs |
using System;
namespace WebApplication10 {
public partial class NextPage : System.Web.UI.Page {
protected void Page_Load( object sender, EventArgs e ) {
Result.Text = "Name: " + Request.Form["Name1"] +
"Email: " + Request.Form["Email1"];
}
}
}
|