• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >ASP.NET > asp.net 中将表单提交到另一页 Code-Behind(代码和html在不同的页面)

asp.net 中将表单提交到另一页 Code-Behind(代码和html在不同的页面)

作者: 字体:[增加 减小] 来源:互联网 时间:2017-05-11

通过本文主要向大家介绍了自定义表单 asp.net,asp.net,asp net培训,asp和asp.net的区别,零基础学asp.net等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
The following shows a complete example of the code-behind file associated with the Web Forms page sending the information. Depending on whether you use Visual Basic or C#, make sure this sample is called Firstpage.aspx.vb or Firstpage.aspx.cs, respectively.
[Visual Basic]
Imports System
Public Class FirstPageClass :
Inherits System.Web.UI.Page
Protected first As System.Web.UI.WebControls.TextBox
Protected last As System.Web.UI.WebControls.TextBox
Protected Button1 As System.Web.UI.WebControls.Button
Public ReadOnly Property FirstName() As String
Get
' first is the name of a TextBox control.
Return first.Text
End Get
End Property
Public ReadOnly Property LastName() As String
Get
' last is the name of a TextBox control.
Return last.Text
End Get
End Property
Sub ButtonClicked(sender As Object, e As EventArgs)
Server.Transfer("secondpage.aspx")
End Sub
End Class
[C#]
using System;
public class FirstPageClass : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox first;
protected System.Web.UI.WebControls.TextBox last;
protected System.Web.UI.WebControls.Button Button1;
public string FirstName
{
get
{
return first.Text;
}
}
public string LastName
{
get
{
return last.Text;
}
}
void ButtonClicked(object sender, EventArgs e)
{
Server.Transfer("secondpage.aspx");
}
}
The following shows a complete example of how to create a Web Forms page with a code-behind file to pass the values of two TextBox controls to another Web Forms page. Make sure this sample is called Firstpage.aspx.
[Visual Basic]
<%@ Page Language="VB" Inherits="FirstPageClass" %>
<html>
<head>
</head>
<body>
<form runat="server">
First Name:
<asp:TextBox id="first"
runat="server"/>
<br>
Last Name:
<asp:TextBox id="last"
runat="server"/>
<br>
<asp:Button
id="Button1"
OnClick="ButtonClicked"
Text="Go to second page"
runat=server />
</form>
</body>
</html>
[C#]
<%@ Page Language="C#" Inherits="FirstPageClass" %>
<html>
<head>
</head>
<body>
<form runat="server">
First Name:
<asp:TextBox id="first"
runat="server"/>
<br>
Last Name:
<asp:TextBox id="last"
runat="server"/>
<br>
<asp:Button
id="Button1"
OnClick="ButtonClicked"
Text="Go to second page"
runat=server />
</form>
</body>
</html>
To receive Server control values from a different Web Forms page
The following shows a complete example of the code-behind file associated with the Web Forms page receiving the information. Depending on whether you use Visual Basic or C#, make sure this sample is called Secondpage.aspx.vb or Secondpage.aspx.cs, respectively.
[Visual Basic]
Imports System
Public Class SecondPageClass
Inherits System.Web.UI.Page
Protected DisplayLabel As System.Web.UI.WebControls.Label
Public fp As FirstPageClass
Sub Page_Load()
If Not IsPostBack Then
fp = CType(Context.Handler, FirstPageClass)
End If
End Sub
End Class
[C#]
using System;
public class SecondPageClass : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label DisplayLabel;
public FirstPageClass fp;
void Page_Load()
{
if (!IsPostBack)
{
fp = (FirstPageClass) Context.Handler;
}
}
}
The following shows a complete example of how to create a Web Forms page with a code-behind file to receive the values passed from a different Web Forms page. Make sure this sample is called Secondpage.aspx
[Visual Basic]
<%@ Page Language="VB" Inherits="SecondPageClass" %>
<%@ Reference Page="firstpage.aspx" %>
<html>
<head>
</head>
<body>
<form runat="server">
Hello <%=fp.FirstName%> <%=fp.LastName%>
</form>
</body>
</html>
[C#]
<%@ Page Language="C#" Inherits="SecondPageClass" %>
<%@ Reference Page="firstpage.aspx" %>
<html>
<head>
</head>
<body>
<form runat="server">
Hello <%=fp.FirstName%> <%=fp.LastName%>
</form>
</body>
</html>
</div>
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • asp.net动态生成HTML表单的方法
  • asp.net DataTable导出Excel自定义列名的方法
  • 基于ASP.NET+EasyUI框架实现图片上传提交表单功能(js提交图片)
  • 基于ASP.NET+easyUI框架实现图片上传功能(表单)
  • Asp.net自定义控件之单选、多选控件
  • Asp.net自定义控件之加载层
  • 在ASP.NET 2.0中操作数据之二十六:排序自定义分页数据
  • 在ASP.NET 2.0中操作数据之十一:基于数据的自定义格式化
  • ASP.NET中防止页面刷新造成表单重复提交执行两次操作
  • asp.net实现取消页面表单内文本输入框Enter响应的方法

相关文章

  • 2017-05-11C#中string与byte[]的转换帮助类-.NET教程,C#语言
  • 2017-05-11推荐8项提高 ASP.NET Web API 性能的技术
  • 2017-05-11C#实现Web文件上传的两种方法实例代码
  • 2018-08-20ng-repeat中Checkbox默认选中的方法教程
  • 2017-05-11asp.net 读取配置文件方法
  • 2017-05-11asp.net图片上传实例
  • 2017-05-11VS2017做为Unity3D的脚本编辑器需要的最精简组件
  • 2017-05-11精彩回顾!Visual Studio 2017正式版发布全纪录
  • 2018-08-20Debian 8或Debian 9(64 位)安装 .NET Core
  • 2017-05-11datatable行转列示例分享

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • ASP.NET技巧:做个DataList可分页的数据源
    • 基于ASP.NET+easyUI框架实现图片上传功能(表单)
    • ASP.NET笔记之CKEditor的使用方法
    • asp.net UpdatePanel实现无刷新上传图片
    • VS2005 水晶报表在时部署时遇到的问题
    • visual studio 2015+opencv2.4.13配置教程
    • 详解ASP.NET MVC之下拉框绑定四种方式
    • Server Application Unavailable出现的原因及解决方案小结
    • ASP.NET MVC中jQuery与angularjs混合应用传参并绑定数据
    • C# 生成验证码取随机数字加字母(改进版)

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有