ASP.NET 跳转页面数据的获取 (使用html控件)

来源:互联网 发布:网络对传统文化的影响 编辑:程序博客网 时间:2024/06/06 16:57

一:注册界面代码

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Reg.aspx.cs" Inherits="WebApplication2.WebForm1" %>


<!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="form" method="get" action="Show.aspx"> 

 // 因为使用的是html的form,按下submit按钮的时候自动跳转到action指定的url,至于要跳转到信息验证c#代码,或者是结果代码页面,自主决定
    <div>  
        你的名字
        <input  type="text" name ="name" />
        <br/>  
       <input type="submit" value="text" />
        <br/>      
        <br/>  
    </div>  
</form>  
</body>
</html>


二:结果界面代码

<%@ Page Language="C#" AutoEventWireup="true" enableviewstatemac="false" CodeBehind="Show1.aspx.cs" Inherits="WebApplication2.Show2" %>


<!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>
     <%=name%>
    </div>
    </form>
</body>
</html>


三:结果界面后台代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


namespace WebApplication2
{
    public partial class Show2 : System.Web.UI.Page
    {
        public String name = "Wxy";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                name = Request.Form["name"];
            }
        }
    }
}

0 0
原创粉丝点击